Demand
In order to achieve the purpose of automatic reading and writing, we need to meet the following requirements:
1, for different formats of the configuration file, just add the appropriate configuration mode interface implementation, you can make the component automatically read the same format configuration file.
2, can easily set the parameters of different modes, such as INI configuration file, we need to set the section, Key,defautvalue and other parameters.
3, all the automatic read and write process is encapsulated in the base class implementation, the user does not need to care about the format of the configuration file, or as in the past must be from the configuration file to read out the corresponding fields and assign values to the corresponding fields in the entity. The consumer only needs to derive an entity class from the base class and define the property fields in that entity class.
4, according to the configuration file, automatic generation of entity class tools
5, support format: support three kinds of common configuration file format, respectively, is Xml,ini and registry. Users can refer to these three configuration patterns, write their own special format of the pattern interface implementation.
Version planning
V1.0 implementation Requirements 1, 2, 3. and provides the pattern interface implementation of Xml,ini two kinds of configuration file formats
V1.1 provides schema interface implementations for registry configuration formats
V1.2 provides an entity class automatic generation tool for the first three modes
Design ideas
As shown in the figure above, the entire component consists of three parts:
The Configuration class is the base class for all configuration file entity classes. All entity classes are derived classes of this base class.
Iconfigurationpattern is the interface of configuration mode
The third part is the implementation class of configuration mode interface, there are two kinds of configuration mode Xmlpattern and Inipattern at present.