public virtual object Create(object parent, object configContext, XmlNode section) { ConfigSettings configSetting; bool flag = false; Enum @enum = DebugLevel.None; string str = null; IEnumerator enumerator = section.ChildNodes.GetEnumerator(); try { if (enumerator.MoveNext()) { XmlNode current = (XmlNode)enumerator.Current; object[] name = new object[1]; name[0] = current.Name; throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, StringResources.ConfigHandlerUnknownConfigSection, name)); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (!flag) { configSetting = new ConfigSettings(); } else { configSetting = new ConfigSettings((DebugLevel)@enum, str); } return configSetting; }
public virtual object Create(object parent, object configContext, XmlNode section) { ConfigSettings configSettings = null; bool foundDebugging = false; System.Enum debugLevelEnum = (System.Enum)GlobalConfig.DefaultDebugLevel; string debugLogFile = null; foreach (XmlNode child in section.ChildNodes) { switch (child.Name) { #if DEBUG case "Debugging": if (foundDebugging) throw new ConfigurationErrorsException( String.Format( CultureInfo.CurrentCulture, StringResources.ConfigHandlerConfigSectionsUnique, "Debugging")); RemoveEnumAttribute(child, "Debugging", "debugLevel", typeof(DebugLevel), ref debugLevelEnum); RemoveStringAttribute(child, "Debugging", "debugLogFile", out debugLogFile); foundDebugging = true; break; #endif default: throw new ConfigurationErrorsException( String.Format( CultureInfo.CurrentCulture, StringResources.ConfigHandlerUnknownConfigSection, child.Name)); } } if (foundDebugging) configSettings = new ConfigSettings((DebugLevel)debugLevelEnum, debugLogFile); else configSettings = new ConfigSettings(); // We need to always return an object so if we haven't read the debug section just create a default object. return (configSettings); }
static GlobalConfig() { GlobalConfig.configSettings = (ConfigSettings)ConfigurationManager.GetSection("System.DirectoryServices.AccountManagement"); }