static WCFConfigProvider() { WCFConfigProvider._serviceAssemblies = null; WCFConfigProvider._contractAssemblies = null; WCFConfigProvider._serviceConfigs = null; WCFConfigProvider._clientConfigs = null; WCFConfigProvider._wcfServiceConfigSection = null; WCFConfigProvider._serviceModel = null; WCFConfigProvider._locker = new object(); if (Path.GetFileName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile).Equals("web.config", StringComparison.CurrentCultureIgnoreCase)) { ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap { ExeConfigFilename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile }; WCFConfigProvider._config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); return; } WCFConfigProvider._config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); }
private static void InitServiceConfigSection() { if (WCFConfigProvider._wcfServiceConfigSection == null) { lock (WCFConfigProvider._locker) { if (WCFConfigProvider._wcfServiceConfigSection == null) { if (WCFConfigProvider._config == null) { throw new ConfigurationErrorsException("配置文件错误!"); } WCFConfigProvider._wcfServiceConfigSection = (WCFConfigProvider._config.Sections["FAF.wcfServices"] as WCFServiceConfigSection); if (WCFConfigProvider._wcfServiceConfigSection == null) { throw new ConfigurationErrorsException("FAF.wcfServices配置文错误!"); } } } } }