. Net Configuration Service

Source: Internet
Author: User
In .net, there are two application configuration files: web.configand .exe. config.
The web.configfile is the configuration information of the asp.net, And the .exe. config file is usable by executable applications. If the application name is test, the configuration file name should be test.exe. config.
Common usage stores some strings, such as database connection strings

String dbCon = ConfigurationManager. ConnectionStrings ["DatabaseConnection"];

By the way, to use ConfigurationManager, You need to introduce the System. Configuration namespace.

Sometimes we need to save many States and rules in the configuration file. In this case, we can use custom configuration information to modify the requirements without modifying the application. In. net, all information in the configuration file must be read through the IConfigurationSectionHandler interface. This interface has only one method.

Object Create (object parent, object configContext, XmlNode section );

The class implementing the IConfigurationSectionHandler interface is responsible for reading the XML Information in the configuration file and processing the configuration information so that it can be converted into an easy-to-use form.

<Configuration>
<ConfigSections>
<Section name = "Football" Type = "Life. Sports, Life"/>
</ConfigSections>
<Football soccer = "Lionel Messi" state = "Argentina"/>
</Configuration>

In the preceding configuration file, configuration data is divided into two groups: section handler group (all content of the configSections tag) and section group
Each segment processor defined in <configSections> implements the ConfigurationSectionHandler interface class.
Recently, the project is not very tight and has plenty of time. I plan to summarize the things used in the previous project. However, there are some strange feelings in the process of writing, but I don't know where it comes from, when I encountered a problem and hoped that google could give me the answer, I realized that my knowledge was outdated, the technology I used to study now has a new set of APIS, and I have never been so easy for a long time. Day-to-day development, the days of little rest have finally passed. I can also have time to learn new knowledge, and learn from the technology system without the name that I used very well.
Sorry!
There is no need to write it down ,:).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.