File tree 1 file changed +17
-12
lines changed
src/NLog.Extensions.Logging/Config 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -348,18 +348,8 @@ private IEnumerable<IConfigurationSection> GetVariablesChildren(IConfigurationSe
348
348
if ( configValue is null )
349
349
continue ;
350
350
351
- var independentVariable = true ;
352
- for ( int j = sortVariables . Count - 1 ; j >= 0 ; j -- )
353
- {
354
- var otherConfigKey = sortVariables [ j ] . Key ;
355
- var referenceVariable = $ "${{{otherConfigKey}}}";
356
- if ( configValue . IndexOf ( referenceVariable , StringComparison . OrdinalIgnoreCase ) >= 0 )
357
- {
358
- independentVariable = false ;
359
- break ;
360
- }
361
- }
362
- if ( independentVariable )
351
+ bool usingOtherVariables = IsNLogConfigVariableValueUsingOthers ( configValue , sortVariables ) ;
352
+ if ( ! usingOtherVariables )
363
353
{
364
354
foundIndependentVariable = true ;
365
355
yield return sortVariables [ i ] . Value ;
@@ -378,6 +368,21 @@ private IEnumerable<IConfigurationSection> GetVariablesChildren(IConfigurationSe
378
368
}
379
369
}
380
370
371
+ private static bool IsNLogConfigVariableValueUsingOthers ( string variableValue , List < KeyValuePair < string , IConfigurationSection > > allVariables )
372
+ {
373
+ foreach ( var otherConfigVariable in allVariables )
374
+ {
375
+ var otherConfigKey = otherConfigVariable . Key ;
376
+ var referenceVariable = $ "${{{otherConfigKey}}}";
377
+ if ( variableValue . IndexOf ( referenceVariable , StringComparison . OrdinalIgnoreCase ) >= 0 )
378
+ {
379
+ return true ;
380
+ }
381
+ }
382
+
383
+ return false ;
384
+ }
385
+
381
386
private static string GetConfigKey ( IConfigurationSection child )
382
387
{
383
388
return child . Key ? . Trim ( ) ?? string . Empty ;
You can’t perform that action at this time.
0 commit comments