public static void AssertName(this ILoggingConfigurationElement section, params string[] allowedNames)
        {
            foreach (var en in allowedNames)
            {
                if (section.MatchesName(en))
                {
                    return;
                }
            }

            throw new InvalidOperationException(
                      $"Assertion failed. Expected element name '{string.Join("|", allowedNames)}', actual: '{section?.Name}'.");
        }
Пример #2
0
 /// <summary>
 /// Parses a single config section within the NLog-config
 /// </summary>
 /// <param name="configSection"></param>
 /// <returns>Section was recognized</returns>
 protected override bool ParseNLogSection(ILoggingConfigurationElement configSection)
 {
     if (configSection.MatchesName("include"))
     {
         string filePath = _currentFilePath.Peek();
         bool   autoLoad = !string.IsNullOrEmpty(filePath) && _fileMustAutoReloadLookup[GetFileLookupKey(filePath)];
         ParseIncludeElement(configSection, !string.IsNullOrEmpty(filePath) ? Path.GetDirectoryName(filePath) : null, autoLoad);
         return(true);
     }
     else
     {
         return(base.ParseNLogSection(configSection));
     }
 }