The ConfigurationManager class is a globally accessible doorway to an application's configuration. Since the class is static, all of its members are also static. This makes reading configuration such as AppSettings, ConnectionStrings and custom configuration sections a breeze. While this is similar to the ConfigurationSettings class, it also provides several new features that allow more secure access to an application's configuration. These new features also allow configuration settings to be saved to any configuration section: custom or otherwise.
Beyond the ConfigurationManager class lies the life-blood of custom configuration sections. The following outlines the base classes available to help you write your own configuration object model. In addition to a set of base classes is a set of validators that can be used to ensure the accuracy of your custom configuration. Also, in the event that your needs are simple enough, a few pre-made configuration sections are available.
The base types
- ConfigurationSection - The base class of all configuration sections
- ConfigurationSectionCollection - The base class of a collection of configuration sections
- ConfigurationSectionGroup - The base class of a configuration section group
- ConfigurationSectionGroupCollection - The base class of a collection of configuration section groups
- ConfigurationElement - The base class of a configuration element
- ConfigurationElementCollection - The base class of a collection of configuration elements
- ConfigurationConverterBase - The base class of a custom converter
- ConfigurationValidatorBase - The base class of a custom validator
The support types
- ConfigurationManager - Allows global access to all of an application's configuration
- Configuration - A class that represents an application's configuration
- ConfigurationProperty - A class that represents a single configuration property
- ConfigurationPropertyAttribute - An attribute class that supports declarative definition of configuration
- ConfigurationPropertyCollection - A collection of configuration properties
- ConfigurationPropertyOptions - Enumeration of possible configuration property options
The validation types
- CallbackValidator - Allows dynamic validation of a configuration value
- CallbackValidatorAttribute - Attribute class for declaratively applying callback validators
- IntegerValidator - Allows validation of an integer (Int32) configuration value
- IntegerValidatorAttribute - Attribute class for declaratively applying integer validators
- LongValidator - Allows validation of a long (Int64) configuration value
- LongValidatorAttribute - Attribute class for declaratively applying long validators
- PositiveTimeSpanValidator - Allows validation of a positive time span configuration value
- PositiveTimeSpanValidatorAttribute - Attribute class for declaratively applying positive time span validators
- RegexStringValidator - Allows validation of a string configuration value with a regular expression
- RegexStringValidatorAttribute - Attribute class for declaratively applying regex validators
- StringValidator - Allows validation of a string configuration value
- StringValidatorAttribute - Attribute class for declaratively applying string validators
- SubclassTypeValidator - Allows validation that a configuration value derives from a given type
- SubclassTypeValidatorAttribute - Attribute class for declaratively applying subclass type validators
- TimeSpanValidator - Allows validation of a time span configuration value
- TimeSpanValidatorAttribute - Attribute class for declaratively applying time span validators
The converter types
- CommaDelimitedStringCollectionConverter - Converts a comma-delimited value to/from CommaDelimitedStringCollection
- GenericEnumConverter - Converts between a string and an enumerated type
- InfiniteIntConverter - Converts between a string and the standard infinite or integer value
- InfiniteTimeSpanConverter - Converts between a string and the standard infinite TimeSpan value
- TimeSpanMinutesConverter - Converts to and from a time span expressed in minutes
- TimeSpanMinutesOrInfiniteConverter - Converts to and from a time span expressed in minutes or infinite
- TimeSpanSecondsConverter - Converts to and from a time span expressed in seconds
- TimeSpanSecondsOrInfiniteConverter - Converts to and from a time span expressed in seconds or infinite
- TypeNameConverter - Converts between a Type object and the string representation of that type
- WhiteSpaceTrimStringConverter - Converts a string to its canonical format, i.e. white space trimmed from front and back
Pre-made configuration sections
- AppSettingsSection - This provides the well-known
configuration section - ConnectionStringsSection - This provides the new
configuration section - ProtectedConfigurationSection - This provides an encrypted configuration section
- IgnoreSection - Special configuration section wrapper that is ignored by the configuration parser
Premade configuration collections
- CommaDelimitedStringCollection - Used in conjunction with CommaDelimitedStringCollectionConverter
- KeyValueConfigurationCollection - Used to configure key/value pairs in your configuration sections
- NameValueConfigurationCollection - Used to configure name/value pairs in your configuration sections
In addition to all of the classes described above, you will also find other support types used by ProtectedConfigurationSection. All of the old .NET 1.x configuration classes will also still be available in the System.Configuration namespace, but for the most part they can be ignored.
No comments:
Post a Comment