| | | 1 | | using pva.SuperV.Engine.Exceptions; |
| | | 2 | | |
| | | 3 | | namespace pva.SuperV.Engine.HistoryStorage |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// HIstory storage engine factory. Based on connection string, the appropriate history storage engine will be creat |
| | | 7 | | /// </summary> |
| | | 8 | | public static class HistoryStorageEngineFactory |
| | | 9 | | { |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Creates the appropriate history storage engine based on connection string. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="connectionString">The connection string.</param> |
| | | 15 | | /// <returns>Created <see cref="IHistoryStorageEngine"/></returns> |
| | | 16 | | /// <exception cref="ArgumentException"></exception> |
| | | 17 | | public static IHistoryStorageEngine? CreateHistoryStorageEngine(string? connectionString) |
| | 195 | 18 | | { |
| | 195 | 19 | | if (string.IsNullOrEmpty(connectionString)) |
| | 13 | 20 | | { |
| | 13 | 21 | | return null; |
| | | 22 | | } |
| | | 23 | | |
| | 182 | 24 | | else if (connectionString.StartsWith(NullHistoryStorageEngine.Prefix)) |
| | 168 | 25 | | { |
| | 168 | 26 | | return new NullHistoryStorageEngine(); |
| | | 27 | | } |
| | | 28 | | |
| | 14 | 29 | | else if (connectionString.StartsWith(TDengineHistoryStorage.Prefix)) |
| | 14 | 30 | | { |
| | 14 | 31 | | string tdEngineConnectionString = connectionString.Replace($"{TDengineHistoryStorage.Prefix}:", "").Trim |
| | 14 | 32 | | return new TDengineHistoryStorage(tdEngineConnectionString); |
| | | 33 | | } |
| | | 34 | | |
| | 0 | 35 | | throw new UnknownHistoryStorageEngineException(connectionString); |
| | 195 | 36 | | } |
| | | 37 | | } |
| | | 38 | | } |