@@ -200,12 +200,12 @@ void ApplyMinimumLevelConfiguration(IConfigurationSection directive, Action<Logg
200200 {
201201 foreach ( var provider in _configurationRoot . Providers . Reverse ( ) )
202202 {
203- if ( provider . TryGet ( minimumLevelDirective . Path , out _ ) )
203+ if ( provider . TryGet ( minimumLevelDirective . Path , out var minValue ) && ! string . IsNullOrEmpty ( minValue ) )
204204 {
205205 return _configurationRoot . GetSection ( minimumLevelDirective . Path ) ;
206206 }
207207
208- if ( provider . TryGet ( defaultLevelDirective . Path , out _ ) )
208+ if ( provider . TryGet ( defaultLevelDirective . Path , out var defaultValue ) && ! string . IsNullOrEmpty ( defaultValue ) )
209209 {
210210 return _configurationRoot . GetSection ( defaultLevelDirective . Path ) ;
211211 }
@@ -303,14 +303,14 @@ void ApplyEnrichment(LoggerConfiguration loggerConfiguration)
303303 }
304304 }
305305
306- internal ILookup < string , Dictionary < string , IConfigurationArgumentValue > > GetMethodCalls ( IConfiguration directive )
306+ internal ILookup < string , Dictionary < string , ConfigurationArgumentValue > > GetMethodCalls ( IConfiguration directive )
307307 {
308308 var children = directive . GetChildren ( ) . ToList ( ) ;
309309
310310 var result =
311311 ( from child in children
312312 where child . Value != null // Plain string
313- select new { Name = child . Value , Args = new Dictionary < string , IConfigurationArgumentValue > ( ) } )
313+ select new { Name = child . Value , Args = new Dictionary < string , ConfigurationArgumentValue > ( ) } )
314314 . Concat (
315315 ( from child in children
316316 where child . Value == null
@@ -319,7 +319,7 @@ internal ILookup<string, Dictionary<string, IConfigurationArgumentValue>> GetMet
319319 select new
320320 {
321321 Name = argument . Key ,
322- Value = GetArgumentValue ( argument , _configurationAssemblies )
322+ Value = ConfigurationArgumentValue . FromSection ( argument , _configurationAssemblies )
323323 } ) . ToDictionary ( p => p . Name , p => p . Value )
324324 select new { Name = name , Args = callArgs } ) )
325325 . ToLookup ( p => p . Name , p => p . Args ) ;
@@ -336,31 +336,6 @@ static string GetSectionName(IConfigurationSection s)
336336 }
337337 }
338338
339- internal static IConfigurationArgumentValue GetArgumentValue ( IConfigurationSection argumentSection , IReadOnlyCollection < Assembly > configurationAssemblies )
340- {
341- IConfigurationArgumentValue argumentValue ;
342-
343- // Reject configurations where an element has both scalar and complex
344- // values as a result of reading multiple configuration sources.
345- if ( argumentSection . Value != null && argumentSection . GetChildren ( ) . Any ( ) )
346- throw new InvalidOperationException (
347- $ "The value for the argument '{ argumentSection . Path } ' is assigned different value " +
348- "types in more than one configuration source. Ensure all configurations consistently " +
349- "use either a scalar (int, string, boolean) or a complex (array, section, list, " +
350- "POCO, etc.) type for this argument value." ) ;
351-
352- if ( argumentSection . Value != null )
353- {
354- argumentValue = new StringArgumentValue ( argumentSection . Value ) ;
355- }
356- else
357- {
358- argumentValue = new ObjectArgumentValue ( argumentSection , configurationAssemblies ) ;
359- }
360-
361- return argumentValue ;
362- }
363-
364339 static IReadOnlyCollection < Assembly > LoadConfigurationAssemblies ( IConfiguration section , AssemblyFinder assemblyFinder )
365340 {
366341 var serilogAssembly = typeof ( ILogger ) . Assembly ;
@@ -404,7 +379,7 @@ This is most likely because the application is published as single-file.
404379 return assemblies ;
405380 }
406381
407- void CallConfigurationMethods ( ILookup < string , Dictionary < string , IConfigurationArgumentValue > > methods , IReadOnlyCollection < MethodInfo > configurationMethods , object receiver )
382+ void CallConfigurationMethods ( ILookup < string , Dictionary < string , ConfigurationArgumentValue > > methods , IReadOnlyCollection < MethodInfo > configurationMethods , object receiver )
408383 {
409384 foreach ( var method in methods . SelectMany ( g => g . Select ( x => new { g . Key , Value = x } ) ) )
410385 {
0 commit comments