Enterprise Library: configuration Application BlockClass Design Analysis
Written by: Rickie Lee (rickieleemail # Yahoo.com)
My blog: www.cnblogs.com/rickie
Configuration Application BlockAllow applicationsProgramEasy to read and write application configuration information.
Shown Configuration Application Block The relationship between classes and objects. This figure assumes that you use Application Block Built-in XML File Storage provider And Transformer , XML File Storage provider Store configuration data XML File (Other Providers Use other Storage Format, such Windows Registry ). Xmlfilestorageprovider The object points to a file that contains the configuration information of a specific configuration section. Configurationbuilder The object points to a file that contains the configuration metadata of a specific configuration section. Generally, the file containing the configuration metadata is Windows Application App. config Or Web Application Web. config File.
Configuration Application Block Isolate the configuration metadata from the actual configuration file, Application Block Store metadata in its own configuration file, which is isolated from the actual configuration information. Configuration settings are combined and used as a configuration section. Every Enterprise Library Of Application Block Use its own configuration section and have corresponding configuration files. Configuration Application Block Use configuration metadata to access configuration data.
Configuration metadata includes the configuration storage location, Transformer Type and Configuration Application Block Used to read and write configuration data Storage provider And so on. The configuration metadata file is divided into configuration sections, each of which contains the necessary information for specific groups in the read/write configuration settings. Configurationmanager Class provides static methods to read and write configurations in the specified configuration section at the defined storage location. First, Configurationmanager The object reads the configuration metadata information from the application configuration metadata file, and then reads and writes the configuration section information through the metadata information.
The settings in each configuration section are cached in Hashtable . When Client When the client requests configuration data, Configurationbuilder The data in the cache will be queried. If the configuration data is found in the cache, Configurationbuilder Objects do not access the configuration data of the bucket. If Storage provider Detects data changes in the storage area, Configurationbuilder The cache is cleared. Configurationmanager Objects allow applications to clear the entire or specific configuration section cache. If the cache is cleared, subsequent requests will access the configuration data in the storage area.
Istorageproviderreader The interface is defined to read configuration information from the storage location, Istorageproviderwriter Interface implementation Istorageproviderreader And defines the interface used to write configuration information. Configuration Application Block In Xmlfilestorageprovider Implemented the above interface for reading and writing XML Configuration file.
Itransformer Interface is used in applications and Storage provider Conversion between configuration objects, Configuration Application Block In Xmlserializertransformer Class. Xmlserializertransformer Class conversion application defined objects and Xmlnode Object. Configuration is not required for Applications Transformer If no Transformer , Returns the configuration setting object for the application and Storage provider Provides the same object type.
***
Author:Rickie Lee (rickieleemail # Yahoo.com)
ReferenceEnterprise Library, configuration Application BlockDocumentation.
References:
1. Enterprise Library, configuration Application Block
2. Rickie, Microsoft patterns & Practices Enterprise Library January 2005 [Medium document],Http://www.cnblogs.com/rickie/archive/2005/01/30/99443.html
3. Rickie, Enterprise Library released!Http://www.cnblogs.com/rickie/archive/2005/01/29/99106.html