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