11using System ;
2+ using System . Collections . Generic ;
23using System . IO ;
34using System . Text . RegularExpressions ;
45using YamlDotNet . Core ;
56using YamlDotNet . Core . Events ;
67using YamlDotNet . Serialization ;
78using YamlDotNet . Serialization . NamingConventions ;
8- using System . Collections . Generic ;
99
10- namespace Cognite . Configuration
10+ namespace Cognite . Extractor . Configuration
1111{
1212 /// <summary>
1313 /// Configuration utility class that uses YamlDotNet to read and deserialize YML documents to extractor config objects.
1414 /// The standard format for extractor config files uses hyphenated tag names (this-is-a-tag in yml is mapped to ThisIsATag object property).
1515 /// Values containing ${ENV_VARIABLE} will be replaced by the environment variable of the same name.
1616 /// </summary>
17- public static class Configuration
17+ public static class ConfigurationUtils
1818 {
1919 private static DeserializerBuilder builder = new DeserializerBuilder ( )
2020 . WithNamingConvention ( HyphenatedNamingConvention . Instance )
@@ -57,7 +57,7 @@ public static T Read<T>(string path)
5757 /// not found or is not of the integer type.</exception>
5858 public static int GetVersionFromFile ( string path )
5959 {
60- Dictionary < object , object > versionedConfig = Configuration . Read < dynamic > ( path ) ;
60+ Dictionary < object , object > versionedConfig = ConfigurationUtils . Read < dynamic > ( path ) ;
6161 return GetVersion ( versionedConfig ) ;
6262 }
6363
@@ -70,7 +70,7 @@ public static int GetVersionFromFile(string path)
7070 /// not found or is not of the integer type.</exception>
7171 public static int GetVersionFromString ( string yaml )
7272 {
73- Dictionary < object , object > versionedConfig = Configuration . ReadString < dynamic > ( yaml ) ;
73+ Dictionary < object , object > versionedConfig = ConfigurationUtils . ReadString < dynamic > ( yaml ) ;
7474 return GetVersion ( versionedConfig ) ;
7575 }
7676
@@ -80,17 +80,17 @@ public static int GetVersionFromString(string yaml)
8080 /// </summary>
8181 /// <param name="yaml">String containing a yaml configuration</param>
8282 /// <param name="acceptedConfigVersions">Accepted versions</param>
83- /// <typeparam name="T">A type that inherits from <see cref="BaseConfig "/></typeparam>
83+ /// <typeparam name="T">A type that inherits from <see cref="VersionedConfig "/></typeparam>
8484 /// <returns>A configuration object of type <typeparamref name="T"/></returns>
8585 /// <exception cref="ConfigurationException">Thrown when the version is not valid or
8686 /// in case of yaml parsing errors.</exception>
8787 public static T TryReadConfigFromString < T > ( string yaml , params int [ ] acceptedConfigVersions ) where T : VersionedConfig
8888 {
8989 try
9090 {
91- int configVersion = Configuration . GetVersionFromString ( yaml ) ;
91+ int configVersion = ConfigurationUtils . GetVersionFromString ( yaml ) ;
9292 CheckVersion ( configVersion , acceptedConfigVersions ) ;
93- return Configuration . ReadString < T > ( yaml ) ;
93+ return ConfigurationUtils . ReadString < T > ( yaml ) ;
9494 }
9595 catch ( YamlDotNet . Core . YamlException ye )
9696 {
@@ -105,18 +105,18 @@ public static T TryReadConfigFromString<T>(string yaml, params int[] acceptedCon
105105 /// </summary>
106106 /// <param name="path">Path to the yml file</param>
107107 /// <param name="acceptedConfigVersions">Accepted versions</param>
108- /// <typeparam name="T">A type that inherits from <see cref="BaseConfig "/></typeparam>
108+ /// <typeparam name="T">A type that inherits from <see cref="VersionedConfig "/></typeparam>
109109 /// <returns>A configuration object of type <typeparamref name="T"/></returns>
110110 /// <exception cref="ConfigurationException">Thrown when the version is not valid,
111111 /// the yaml file is not found or in case of yaml parsing error.</exception>
112- public static T TryReadConfigFromFile < T > ( string path , params int [ ] acceptedConfigVersions )
112+ public static T TryReadConfigFromFile < T > ( string path , params int [ ] acceptedConfigVersions ) where T : VersionedConfig
113113 {
114114 try
115115 {
116- int configVersion = Configuration . GetVersionFromFile ( path ) ;
116+ int configVersion = ConfigurationUtils . GetVersionFromFile ( path ) ;
117117 CheckVersion ( configVersion , acceptedConfigVersions ) ;
118118
119- return Configuration . Read < T > ( path ) ;
119+ return ConfigurationUtils . Read < T > ( path ) ;
120120 }
121121 catch ( System . IO . FileNotFoundException fnfe )
122122 {
0 commit comments