. Net application configuration and basic configuration methods (1). net basic configuration
I. How should I configure an application?
1. Create an XML file as the configuration file, define the required node or node tree, and store the parameter values in the node attributes or text.
2. Create a class, for example, ForumConfig. The attributes of this class are mapped to the names and attributes of a configuration node in XML to provide strong type access.
3. Create a configuration file lifecycle class, such as ConfigManager. add a method, such as GetSection (string nodeName), and then use System. the method in the Xml namespace obtains the node attribute value or text value. Finally, assign values to the attributes of the ForumConfig instance, and then return the instance.
4. Access the configured node value through an instance similar to ForumConfig in the program.
2. Structure of the application configuration file in. net:
The configuration file is divided into two parts: the actual configuration content;
The other part specifies the node handler.
(In general, it is the class information of configuration information + operation configuration information)
The built-in node settings are all located:
C: \ Windows \ Microsoft. NET \ Framework \ v4.0.30319 \ Config
To provide global services. (Slightly different)
3. Two types of handlers in machine. config
4. Demo
When the configuration file was first used to load the assembly, the built-in. net handler was defined in machine. config to provide global services, which can be directly used without additional work.
Read configuration information in the program:
Not yet to be continued ....