view Source/Configuration/BLToolkitSection.cs @ 9:1e85f66cf767 default tip

update bltoolkit
author nickolay
date Thu, 05 Apr 2018 20:53:26 +0300
parents f990fcb411a9
children
line wrap: on
line source

using System;
using System.Configuration;
using System.Security;

namespace BLToolkit.Configuration
{
	/// <summary>
	/// Implementation of custom configuration section.
	/// </summary>
	internal class BLToolkitSection : ConfigurationSection
	{
		private const string SectionName = "bltoolkit";
		private static readonly ConfigurationPropertyCollection _properties =
			new ConfigurationPropertyCollection();

		private static readonly ConfigurationProperty           _propDataProviders = 
			new ConfigurationProperty("dataProviders",           typeof(DataProviderElementCollection),
			new DataProviderElementCollection(),                 ConfigurationPropertyOptions.None);
		private static readonly ConfigurationProperty           _propDefaultConfiguration =
			new ConfigurationProperty("defaultConfiguration",    typeof(string),
			null,                                                ConfigurationPropertyOptions.None);
		private static readonly ConfigurationProperty           _propTypeFactory =
			new ConfigurationProperty("typeFactory",             typeof(TypeFactoryElement),
			null,                                                ConfigurationPropertyOptions.None);

		static BLToolkitSection()
		{
			_properties.Add(_propDataProviders);
			_properties.Add(_propDefaultConfiguration);
			_properties.Add(_propTypeFactory);
		}

		public static BLToolkitSection Instance
		{
			get
			{
				try
				{
					return (BLToolkitSection)ConfigurationManager.GetSection(SectionName);
				}
				catch (SecurityException)
				{
					return null;
				}
			}
		}

		protected override ConfigurationPropertyCollection Properties
		{
			get { return _properties; }
		}

		public DataProviderElementCollection DataProviders
		{
			get { return (DataProviderElementCollection) base[_propDataProviders]; }
		}

		public string DefaultConfiguration
		{
			get { return (string)base[_propDefaultConfiguration]; }
		}

		public TypeFactoryElement TypeFactory
		{
			get { return (TypeFactoryElement)base[_propTypeFactory]; }
		}
	}
}