/// <summary> /// 测试 单节点配置信息 获取 /// </summary> public static void TestConfigInfo() { #region 单级配置节点测试 Console.WriteLine("---------------------多级配置节点测试-----------------"); Console.WriteLine("enabled:" + CustomerMultiConfig.GetConfig().CustomerElementConfig.Enabled); Console.WriteLine("connectionString:" + CustomerMultiConfig.GetConfig().CustomerElementConfig.ConnectionString); #endregion }
/// <summary> /// 获取配置信息 /// </summary> /// <param name="sectionName">xml节点名称</param> /// <returns></returns> public static CustomerMultiConfig GetConfig(string sectionName) { CustomerMultiConfig section = (CustomerMultiConfig)ConfigurationManager.GetSection(sectionName); if (section == null) { throw new ConfigurationErrorsException("Section " + sectionName + " is not found."); } return(section); }