Пример #1
0
        /// <summary>
        /// 获取最终 local 和 global 合并后的 Configuration
        /// </summary>
        /// <param name="fileSettings">ConfigFilesSetting 类实例</param>
        /// <returns>local 和 global 合并后的 Configuration</returns>
        private static System.Configuration.Configuration GetFinalConfiguration(ConfigFilesSetting fileSettings)
        {
            System.Configuration.Configuration config;

            if (EnvironmentHelper.Mode == InstanceMode.Web)
            {
                config = ConfigurationBroker.GetStandardWebConfiguration(
                    fileSettings.GlobalConfigurationFile,
                    true,
                    fileSettings.LocalConfigurationFile,
                    fileSettings.MachineConfigurationFile,
                    fileSettings.MetaConfigurationFile);
            }
            else
            {
                config = ConfigurationBroker.GetStandardExeConfiguration(fileSettings.GlobalConfigurationFile,
                                                                         fileSettings.LocalConfigurationFile,
                                                                         true,
                                                                         fileSettings.MachineConfigurationFile,
                                                                         fileSettings.MetaConfigurationFile);
            }

            return(config);
        }
Пример #2
0
        /// <summary>
        /// 从本地config文件中读取meta配置
        /// </summary>
        /// <param name="fileSettings">ConfigFilesSetting 类实例</param>
        /// <returns>MetaConfigurationSourceInstanceSection 实体</returns>
        private static MetaConfigurationSourceInstanceSection LoadMetaSourceInstanceSectionFromLocal(ConfigFilesSetting fileSettings)
        {
            System.Configuration.Configuration config;

            if (EnvironmentHelper.Mode == InstanceMode.Web)
            {
                config = ConfigurationBroker.GetStandardWebConfiguration(fileSettings.MachineConfigurationFile, true);
            }
            else
            {
                config = ConfigurationBroker.GetStandardExeConfiguration(fileSettings.MachineConfigurationFile, fileSettings.LocalConfigurationFile, true);
            }

            MetaConfigurationSectionGroup group =
                (MetaConfigurationSectionGroup)config.GetSectionGroup(ConfigurationBroker.MetaConfigurationSectionGroupItem);
            MetaConfigurationSourceInstanceSection section = null;

            if (group != null)
            {
                section = group.SourceConfigurationMapping;
            }

            return(section);
        }