protected override object OnCreate(string sectionName, Type type, out int major, out int minor) { major = XmlSerializerSectionHandler.GetConfigurationClassMajorVersion(type); minor = XmlSerializerSectionHandler.DefaultUninitMinorVersion; string configPath = GetConfigSectionFileName(sectionName); if (configPath.Length == 0) { return(null); } object retVal; try { XmlDocument doc = new XmlDocument(); doc.Load(configPath); retVal = XmlSerializerSectionHandler.GetConfigInstance(doc.DocumentElement, type); XmlSerializerSectionHandler.GetConfigVersion(doc.DocumentElement, out major, out minor); } catch (Exception ex) { HandleException(ex, "Error when create local configuration: sectionName=" + sectionName + ",type=" + type.Name + ", create entry config instead", sectionName); //if exception here, return default configuration class and then setup watch retVal = Activator.CreateInstance(type); } XmlSerializerSectionHandler.SetupWatcher(configPath, retVal); return(retVal); }
void CheckDownloadStream(string sectionName, Stream stream) { ConfigEntry entry = this.GetEntry(sectionName); if (entry == null) { throw new System.Configuration.ConfigurationErrorsException("No entry '" + sectionName + "' in RemoteConfigurationManager"); } XmlDocument doc = new XmlDocument(); doc.Load(stream); XmlSerializerSectionHandler.GetConfigInstance(doc.DocumentElement, entry.EntryType); }
public static object CreateAndSetupWatcher(XmlNode section, string path, Type type, EventHandler OnConfigFileChangedByFile ) { object obj = XmlSerializerSectionHandler.GetConfigInstance(section, type); SetupWatcher(path, obj); if (OnConfigFileChangedByFile != null) { RegisterReloadNotification(path, OnConfigFileChangedByFile); } return(obj); }