public object Create(object parent, object configContext, XmlNode section) { WebManagerCfg cfg = new WebManagerCfg(); PropertyInfo[] cfgProps = cfg.GetType().GetProperties(); foreach (PropertyInfo cfgProp in cfgProps) { // check attr first string propValue = null; if (section.Attributes[cfgProp.Name] != null) { propValue = section.Attributes[cfgProp.Name].Value; } else { XmlNode propNode = section.SelectSingleNode(cfgProp.Name); if (propNode != null) { propValue = propNode.InnerText; } } if (propValue != null) { cfgProp.SetValue(cfg, Convert.ChangeType(propValue, cfgProp.PropertyType), null); } } return(cfg); }
public static void Configure() { string sectionName = typeof(WebManager).Namespace; object config = ConfigurationSettings.GetConfig(sectionName); if (config == null) { config = ConfigurationSettings.GetConfig(sectionName.ToLower()); } if (config != null) { WebManagerCfg webCfg = config as WebManagerCfg; if (config == null) { log.Write(LogEvent.Warn, "Invalid WebManager configuration type: {0}", config.GetType()); } else { Config = webCfg; } } else { log.Write(LogEvent.Warn, "WebManager configuration section not found in application config"); } }
public object Create(object parent, object configContext, XmlNode section) { WebManagerCfg cfg = new WebManagerCfg(); PropertyInfo[] cfgProps = cfg.GetType().GetProperties(); foreach (PropertyInfo cfgProp in cfgProps) { // check attr first string propValue = null; if (section.Attributes[cfgProp.Name] != null) { propValue = section.Attributes[cfgProp.Name].Value; } else { XmlNode propNode = section.SelectSingleNode(cfgProp.Name); if (propNode != null) { propValue = propNode.InnerText; } } if (propValue != null) { cfgProp.SetValue(cfg, Convert.ChangeType(propValue, cfgProp.PropertyType), null); } } return cfg; }
public static void Configure(WebManagerCfg cfg) { Config = cfg; }