Ejemplo n.º 1
0
        /// <summary>
        ///     Creates a configuration section handler.
        /// </summary>
        /// <param name="parent">Parent object.</param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="dynamicConfigurationSection">XML section as an XMLnode.</param>
        /// <returns>A NameValueCollection of new application settings.</returns>
        public object Create(object parent, object configContext, XmlNode dynamicConfigurationSection)
        {
            // Throw error if null section
            if (dynamicConfigurationSection == null)
            {
                throw new ConfigurationErrorsException("The 'DynamicConfigurationManagerSection' node is not found in app.config.");
            }

            var newdcm = new DynamicConfigurationBuilder().Build(dynamicConfigurationSection);

            // Parse the config to build up the settings
            ParseConfig(dynamicConfigurationSection);

            // Check if configMaps found
            if (NumOfHandledConfigMaps == 0)
            {
                throw new ConfigurationErrorsException("Zero configMaps handled, validate configMap attribute settings and values entered.");
            }

            // Copy dynamic settings to the appSettings global and export to the environment with the "DCM" prefix for sub-process consumption
            MergeToAppSettingsAndExport();

            return(_dynamicConfigAppsettings);
        }
        /// <summary>
        ///     Creates a configuration section handler.
        /// </summary>
        /// <param name="parent">Parent object.</param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="dynamicConfigurationSection">XML section as an XMLnode.</param>
        /// <returns>A NameValueCollection of new application settings.</returns>
        public object Create(object parent, object configContext, XmlNode dynamicConfigurationSection)
        {
            // Throw error if null section
            if (dynamicConfigurationSection == null)
            {
                throw new ConfigurationErrorsException("The 'DynamicConfigurationManagerSection' node is not found in app.config.");
            }

            var newdcm = new DynamicConfigurationBuilder().Build(dynamicConfigurationSection);

            // Parse the config to build up the settings
            ParseConfig(dynamicConfigurationSection);

            // Check if configMaps found
            if (NumOfHandledConfigMaps == 0)
            {
                throw new ConfigurationErrorsException("Zero configMaps handled, validate configMap attribute settings and values entered.");
            }

            // Copy dynamic settings to the appSettings global and export to the environment with the "DCM" prefix for sub-process consumption
            MergeToAppSettingsAndExport();

            return _dynamicConfigAppsettings;
        }