/// <summary> /// Called by the XmlSerializationSectionHandler to deserialize a /// settings object for the first time. If that object inherits from /// XmlSectionSettingsBase, then we make it watch for changes to the /// config file. /// </summary> /// <param name="section"></param> /// <returns></returns> public static object LoadSettings(XmlNode section) { object settings = DeserializeSection(section); XmlSectionSettingsBase xmlSettings = settings as XmlSectionSettingsBase; if (xmlSettings != null) { xmlSettings._rootName = section.Name; ((XmlSectionSettingsBase)settings).WatchForConfigChanges(); } return(settings); }
/// <summary> /// Reloads setting values from the configuration file. /// </summary> void ReloadSettings() { XmlDocument doc = new XmlDocument(); doc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); XmlNodeList nodes = doc.GetElementsByTagName(_rootName); if (nodes.Count > 0) { //Note: newSettings should not watch for config changes. XmlSectionSettingsBase newSettings = DeserializeSection(nodes[0]) as XmlSectionSettingsBase; newSettings._isDataValid = true; CopySettings(newSettings); } else { throw new System.Configuration.ConfigurationException("Configuration section " + _rootName + " not found."); } }
public object Create(object parent, object context, XmlNode section) { return(XmlSectionSettingsBase.LoadSettings(section)); }