Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace)
- Configuration class and ConfigurationManager class
- ConfigurationSettings class, ConfigurationElement class, ConfigurationElementCollection class, and ConfigurationElementProperty class
- Implement IConfigurationSectionHandler interface
- ConfigurationSection class, ConfigurationSectionCollection class, ConfigurationSectionGroup class, and ConfigurationSectionGroupCollection class
- Implement ISettingsProviderService interface
- Implement IApplicationSettingsProvider interface
- ConfigurationValidationBase class
- Implement IConfigurationSystem interface
.Net 2.0 has completely revamped how it handles Configuration. So much in so, that Enterprise Library 2.0 no longer contains a Configuration Application Block since most of the functionality that it exposed is built right into the core .Net library.
The Configuration Class represents a merged view of the configuration settings that apply to a physical or logical entity (computer, application, web site etc). This class exposes AppSettings (Collection of Name Value Pairs), ConnectionStrings (Configuration Section designed specifically for Connection Strings), A Collection of Sections and Section Groups (for dealing with other types of sections. It also exposes methods to retrieve Sections in a variety of ways as well as has the ability to save changes or save Changes to another file (Save as).
The Configuration Manager Class gives you the ability to access a particular application’s Configuration Class Instance. It exposes methods like OpenExeConfiguration, OpenMachineConfiguration, OpenMappedExeConfiguration, OpenMappedMachineConfiguration to obtain handles to configurations. It also exposes a RefreshSection method to refresh the named section. It also has AppSettings and ConnectionString properties which return the section for the current applications configuration.
The ConfigurationSettings Class exposes the AppSettings object and the GetSection method in a read only fashion.
The ConfigurationElement class represents a section that is serialized into Xml like AppSettings and ConnectionStrings. It uses Attributes to define its default value, validation rules among other features. The public methods will be mapped to attributes of the add node in Xml.
The ConfigurationElementCollection Represents a Collection of Configuration Elements. A good way to think of this is in terms of AppSettings. Each Add Node represents one Configuration Element instance with two public properties: name and value. All the different Add Nodes together are the ConfigurationElementCollection. And to tie it all together the Configuration Section represents the Configuration Section and Contains the ConfigurationElementCollection that is contains.
Every ConfigurationElement object creates an internal ConfigurationPropertyCollection collection of ConfigurationProperty objects that represents either the element attributes or a collection of child elements. A ConfigurationElementProperty instance can be used to apply validation rules. (I suspect these properties can be specified as attributes, but am not sure).
The IConfigurationSectionHandler is used to define the interface for creating a ConfigurationSectionHandler. To implement this interface simply expose a Create Method that returns an Object.
The ConfigurationSection Class represents one Node that may contain a ConfigurationElement or ConfigurationElementCollection. It exposes properties to lock Elements and attributes for editing and retrieve elements. The ConfigurationSectionCollection Class represents a collection of ConfigurationSections. It exposes methods for managing the Collection of sections (Add, Remove, count, etc).
The ConfigurationSectionGroup Class represents the container for groups of ConfigurationSections. The ConfigurationSectionGroupCollection allows you to ititerate through all the ConfigurationSettingGroups in a configuration. The Configuration Class mentioned in the second paragraph of this section exposes a ConfigurationSettingsGroupCollection which gives you access to ConfigurationSectionGroups which give you access to ConfigurationSection Collections and so on.
The ISettingsProviderService interface defines the interface for providing an alternative application settings provider. To implement this interface provide a GetSettingsProvider method which returns an object that derives from the SettingsProvider Class. This object exposes methods like GetPropertyValues and SetPropertyValues. The only SettingsProvider that comes with the core library is the LocalFileSettingsProvider which stores it to the filesystem as Xml.
The IApplicationSettingsProvider Interface defines the interface for providing custom storage for applicationsettings. It is the interface that the SettingsProvider Class and LocalFileSettingsProvider Class implement.
The ConfigurationValidatorBase Class is the base class for creating custom validators that can be applied to ConfigurationElementProperties.
The IConfigurationSystem interface defines the interface for providing access to configuration. It exposes two methods: GetConfig and Init. GetConfig returns an Object.
Other Resources & Links:
List of Items In Configuration Files