@@ -146,7 +146,10 @@ public static string Get(string key, string defaultValue = "")
146146 var token = GetToken ( Settings . Value , key ) ;
147147 if ( token == null )
148148 {
149- Log . Trace ( Invariant ( $ "Config.Get(): Configuration key not found. Key: { key } - Using default value: { defaultValue } ") ) ;
149+ if ( Log . DebuggingEnabled )
150+ {
151+ Log . Debug ( Invariant ( $ "Config.Get(): Configuration key not found. Key: { key } - Using default value: { defaultValue } ") ) ;
152+ }
150153 return defaultValue ;
151154 }
152155 return token . ToString ( ) ;
@@ -227,18 +230,21 @@ public static double GetDouble(string key, double defaultValue = 0.0)
227230 public static T GetValue < T > ( string key , T defaultValue = default ( T ) )
228231 {
229232 // special case environment requests
230- if ( key == "environment" && typeof ( T ) == typeof ( string ) ) return ( T ) ( object ) GetEnvironment ( ) ;
233+ if ( key == "environment" && typeof ( T ) == typeof ( string ) ) return ( T ) ( object ) GetEnvironment ( ) ;
231234
232235 var token = GetToken ( Settings . Value , key ) ;
233236 if ( token == null )
234237 {
235238 var defaultValueString = defaultValue is IConvertible
236- ? ( ( IConvertible ) defaultValue ) . ToString ( CultureInfo . InvariantCulture )
239+ ? ( ( IConvertible ) defaultValue ) . ToString ( CultureInfo . InvariantCulture )
237240 : defaultValue is IFormattable
238- ? ( ( IFormattable ) defaultValue ) . ToString ( null , CultureInfo . InvariantCulture )
241+ ? ( ( IFormattable ) defaultValue ) . ToString ( null , CultureInfo . InvariantCulture )
239242 : Invariant ( $ "{ defaultValue } ") ;
240243
241- Log . Trace ( Invariant ( $ "Config.GetValue(): { key } - Using default value: { defaultValueString } ") ) ;
244+ if ( Log . DebuggingEnabled )
245+ {
246+ Log . Debug ( Invariant ( $ "Config.GetValue(): { key } - Using default value: { defaultValueString } ") ) ;
247+ }
242248 return defaultValue ;
243249 }
244250
@@ -255,22 +261,22 @@ public static double GetDouble(string key, double defaultValue = 0.0)
255261
256262 if ( type . IsEnum )
257263 {
258- return ( T ) Enum . Parse ( type , value , true ) ;
264+ return ( T ) Enum . Parse ( type , value , true ) ;
259265 }
260266
261267 if ( typeof ( IConvertible ) . IsAssignableFrom ( type ) )
262268 {
263- return ( T ) Convert . ChangeType ( value , type , CultureInfo . InvariantCulture ) ;
269+ return ( T ) Convert . ChangeType ( value , type , CultureInfo . InvariantCulture ) ;
264270 }
265271
266272 // try and find a static parse method
267273 try
268274 {
269- var parse = type . GetMethod ( "Parse" , new [ ] { typeof ( string ) } ) ;
275+ var parse = type . GetMethod ( "Parse" , new [ ] { typeof ( string ) } ) ;
270276 if ( parse != null )
271277 {
272- var result = parse . Invoke ( null , new object [ ] { value } ) ;
273- return ( T ) result ;
278+ var result = parse . Invoke ( null , new object [ ] { value } ) ;
279+ return ( T ) result ;
274280 }
275281 }
276282 catch ( Exception err )
@@ -381,7 +387,7 @@ public static JObject Flatten(JObject config, string overrideEnvironment)
381387 var environments = config [ "environments" ] ;
382388 if ( ! ( environments is JObject ) ) continue ;
383389
384- var settings = ( ( JObject ) environments ) . SelectToken ( env ) ;
390+ var settings = ( ( JObject ) environments ) . SelectToken ( env ) ;
385391 if ( settings == null ) continue ;
386392
387393 // copy values for the selected environment to the root
@@ -395,7 +401,7 @@ public static JObject Flatten(JObject config, string overrideEnvironment)
395401 var jProperty = clone . Property ( path ) ;
396402 if ( jProperty != null ) jProperty . Remove ( ) ;
397403
398- var value = ( token is JProperty ? ( ( JProperty ) token ) . Value : token ) . ToString ( ) ;
404+ var value = ( token is JProperty ? ( ( JProperty ) token ) . Value : token ) . ToString ( ) ;
399405 clone . Add ( path , value ) ;
400406 }
401407 }
0 commit comments