@@ -200,12 +200,12 @@ void ApplyMinimumLevelConfiguration(IConfigurationSection directive, Action<Logg
200
200
{
201
201
foreach ( var provider in _configurationRoot . Providers . Reverse ( ) )
202
202
{
203
- if ( provider . TryGet ( minimumLevelDirective . Path , out _ ) )
203
+ if ( provider . TryGet ( minimumLevelDirective . Path , out var minValue ) && ! string . IsNullOrEmpty ( minValue ) )
204
204
{
205
205
return _configurationRoot . GetSection ( minimumLevelDirective . Path ) ;
206
206
}
207
207
208
- if ( provider . TryGet ( defaultLevelDirective . Path , out _ ) )
208
+ if ( provider . TryGet ( defaultLevelDirective . Path , out var defaultValue ) && ! string . IsNullOrEmpty ( defaultValue ) )
209
209
{
210
210
return _configurationRoot . GetSection ( defaultLevelDirective . Path ) ;
211
211
}
@@ -303,14 +303,14 @@ void ApplyEnrichment(LoggerConfiguration loggerConfiguration)
303
303
}
304
304
}
305
305
306
- internal ILookup < string , Dictionary < string , IConfigurationArgumentValue > > GetMethodCalls ( IConfiguration directive )
306
+ internal ILookup < string , Dictionary < string , ConfigurationArgumentValue > > GetMethodCalls ( IConfiguration directive )
307
307
{
308
308
var children = directive . GetChildren ( ) . ToList ( ) ;
309
309
310
310
var result =
311
311
( from child in children
312
312
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 > ( ) } )
314
314
. Concat (
315
315
( from child in children
316
316
where child . Value == null
@@ -319,7 +319,7 @@ internal ILookup<string, Dictionary<string, IConfigurationArgumentValue>> GetMet
319
319
select new
320
320
{
321
321
Name = argument . Key ,
322
- Value = GetArgumentValue ( argument , _configurationAssemblies )
322
+ Value = ConfigurationArgumentValue . FromSection ( argument , _configurationAssemblies )
323
323
} ) . ToDictionary ( p => p . Name , p => p . Value )
324
324
select new { Name = name , Args = callArgs } ) )
325
325
. ToLookup ( p => p . Name , p => p . Args ) ;
@@ -336,31 +336,6 @@ static string GetSectionName(IConfigurationSection s)
336
336
}
337
337
}
338
338
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
-
364
339
static IReadOnlyCollection < Assembly > LoadConfigurationAssemblies ( IConfiguration section , AssemblyFinder assemblyFinder )
365
340
{
366
341
var serilogAssembly = typeof ( ILogger ) . Assembly ;
@@ -404,7 +379,7 @@ This is most likely because the application is published as single-file.
404
379
return assemblies ;
405
380
}
406
381
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 )
408
383
{
409
384
foreach ( var method in methods . SelectMany ( g => g . Select ( x => new { g . Key , Value = x } ) ) )
410
385
{
0 commit comments