Click here to Skip to main content
15,896,111 members
Articles / Web Development / HTML

Transformalizing NorthWind

Rate me:
Please Sign up or sign in to vote.
4.95/5 (29 votes)
24 Jul 2014GPL37 min read 57.8K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
//===============================================================================
// Microsoft patterns & practices Enterprise Library
// Core
//===============================================================================
// Copyright © Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System.Configuration;
using Transformalize.Libs.EnterpriseLibrary.Common.Configuration.Design;
using Transformalize.Libs.EnterpriseLibrary.Common.Configuration.Design.Validation;

namespace Transformalize.Libs.EnterpriseLibrary.Common.Configuration
{
    /// <summary>
    /// Configuration section for the configuration sources.
    /// </summary>
	/// <remarks>
	/// This configuration must reside in the application's default configuration file.
	/// </remarks>
    [ViewModel(ConfigurationSourcesDesignTime.ViewModelTypeNames.ConfigurationSourceSectionViewModel)]
    [ResourceDescription(typeof(DesignResources), "ConfigurationSourceSectionDescription")]
    [ResourceDisplayName(typeof(DesignResources), "ConfigurationSourceSectionDisplayName")]
    [EnvironmentalOverrides(false)]
    public class ConfigurationSourceSection : SerializableConfigurationSection
    {
        private const string selectedSourceProperty = "selectedSource";
        private const string sourcesProperty = "sources";
        private const string parentSourceProperty = "parentSource";
        private const string redirectSectionsProperty = "redirectSections";

        /// <summary>
		/// This field supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// </summary>
        public const string SectionName = "enterpriseLibrary.ConfigurationSource";        

        /// <summary>
		/// Returns the <see cref="ConfigurationSourceSection"/> from the application's default configuration file.
        /// </summary>
		/// <returns>The section from the configuration file, or <see langword="null"/> (<b>Nothing</b> in Visual Basic) if the section is not present in the configuration file.</returns>
        public static ConfigurationSourceSection GetConfigurationSourceSection()
        {
			return (ConfigurationSourceSection)ConfigurationManager.GetSection(SectionName);
        }

        /// <summary>
        /// Gets or sets the name for the default configuration source.
        /// </summary>
        [ConfigurationProperty(selectedSourceProperty, IsRequired=true)]
        [ResourceDescription(typeof(DesignResources), "ConfigurationSourceSectionSelectedSourceDescription")]
        [ResourceDisplayName(typeof(DesignResources), "ConfigurationSourceSectionSelectedSourceDisplayName")]
        [Reference(typeof(CustomConfigurationElementCollection<ConfigurationSourceElement, ConfigurationSourceElement>), typeof(ConfigurationSourceElement))]
        [Validation(CommonDesignTime.ValidationTypeNames.SelectedSourceValidator)]
        public string SelectedSource
        {
            get
            {
                return (string)this[selectedSourceProperty];
            }
			set
			{
				this[selectedSourceProperty] = value;
			}
        }

        /// <summary>
        /// Gets or sets the name for the parent configuration source.
        /// </summary>
        [ConfigurationProperty(parentSourceProperty)]
        [ResourceDescription(typeof(DesignResources), "ConfigurationSourceSectionParentSourceDescription")]
        [ResourceDisplayName(typeof(DesignResources), "ConfigurationSourceSectionParentSourceDisplayName")]
        [Reference(typeof(CustomConfigurationElementCollection<ConfigurationSourceElement, ConfigurationSourceElement>), typeof(ConfigurationSourceElement))]
        public string ParentSource
        {
            get
            {
                return (string)this[parentSourceProperty];
            }
            set
            {
                this[parentSourceProperty] = value;
            }
        }

        /// <summary>
        /// Gets the collection of defined configuration sources.
        /// </summary>
        [ConfigurationProperty(sourcesProperty, IsRequired = true)]
        [ConfigurationCollection(typeof(ConfigurationSourceElement))]
        [ResourceDescription(typeof(DesignResources), "ConfigurationSourceSectionSourcesDescription")]
        [ResourceDisplayName(typeof(DesignResources), "ConfigurationSourceSectionSourcesDisplayName")]
        public CustomConfigurationElementCollection<ConfigurationSourceElement, ConfigurationSourceElement> Sources
        {
            get
            {
                return (CustomConfigurationElementCollection<ConfigurationSourceElement, ConfigurationSourceElement>)this[sourcesProperty];
            }           

        }

        /// <summary>
        /// Gets the collection of redirected sections.
        /// </summary>
        [ConfigurationProperty(redirectSectionsProperty)]
        [ResourceDescription(typeof(DesignResources), "ConfigurationSourceSectionRedirectedSectionsDescription")]
        [ResourceDisplayName(typeof(DesignResources), "ConfigurationSourceSectionRedirectedSectionsDisplayName")]
        [ConfigurationCollection(typeof(RedirectedSectionElement))]
        public NamedElementCollection<RedirectedSectionElement> RedirectedSections
        {
            get
            {
                return (NamedElementCollection<RedirectedSectionElement>)this[redirectSectionsProperty];
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions