Configuration section for bootstrapper extensions.
Наследование: System.Configuration.ConfigurationSection
        /// <summary>
        /// Applies the extension configuration section loading behavior to the extensions.
        /// </summary>
        /// <param name="extensions">The extensions.</param>
        public void Behave(IEnumerable <IExtension> extensions)
        {
            Ensure.ArgumentNotNull(extensions, "extensions");

            foreach (IExtension extension in extensions)
            {
                IHaveConfigurationSectionName sectionNameProvider = this.factory.CreateHaveConfigurationSectionName(extension);
                ILoadConfigurationSection     sectionProvider     = this.factory.CreateLoadConfigurationSection(extension);

                ExtensionConfigurationSection section = GetExtensionConfigurationSection(sectionNameProvider, sectionProvider);

                if (!section.Configuration.OfType <ExtensionSettingsElement>().Any())
                {
                    continue;
                }

                IConsumeConfiguration consumer = this.factory.CreateConsumeConfiguration(extension);

                FillConsumerConfiguration(section, consumer);

                IHaveConversionCallbacks       conversionCallbacksProvider       = this.factory.CreateHaveConversionCallbacks(extension);
                IHaveDefaultConversionCallback defaultConversionCallbackProvider = this.factory.CreateHaveDefaultConversionCallback(extension);

                this.assignExtensionProperties.Assign(this.reflectExtensionProperties, extension, consumer, conversionCallbacksProvider, defaultConversionCallbackProvider);
            }
        }
        private static void FillConsumerConfiguration(ExtensionConfigurationSection section, IConsumeConfiguration consumer)
        {
            foreach (ExtensionSettingsElement settingsElement in section.Configuration)
            {
                string key   = settingsElement.Key;
                string value = settingsElement.Value;

                consumer.Configuration.Add(key, value);
            }
        }
        /// <summary>
        /// Creates a <see cref="ExtensionConfigurationSection"/> according to the provided settings dictionary.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>A newly created <see cref="ExtensionConfigurationSection"/>.</returns>
        public static ExtensionConfigurationSection CreateSection(params KeyValuePair<string, string>[] settings)
        {
            var section = new ExtensionConfigurationSection();
            var elementCollection = new ExtensionSettingsElementCollection();

            foreach (ExtensionSettingsElement element in settings.Select(settingPair => new ExtensionSettingsElement { Key = settingPair.Key, Value = settingPair.Value }))
            {
                elementCollection["Configuration"] = element;
            }

            section.Configuration = elementCollection;

            return section;
        }
Пример #4
0
        /// <summary>
        /// Creates a <see cref="ExtensionConfigurationSection"/> according to the provided settings dictionary.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>A newly created <see cref="ExtensionConfigurationSection"/>.</returns>
        public static ExtensionConfigurationSection CreateSection(params KeyValuePair <string, string>[] settings)
        {
            var section           = new ExtensionConfigurationSection();
            var elementCollection = new ExtensionSettingsElementCollection();

            foreach (ExtensionSettingsElement element in settings.Select(settingPair => new ExtensionSettingsElement {
                Key = settingPair.Key, Value = settingPair.Value
            }))
            {
                elementCollection["Configuration"] = element;
            }

            section.Configuration = elementCollection;

            return(section);
        }