Mercurial > pub > bltoolkit
diff Source/Configuration/BLToolkitSection.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Source/Configuration/BLToolkitSection.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,68 @@ +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]; } + } + } +}