在.NET框架下使用自定义配置设置(Use the custom configuration settings in the.NET framework).doc
文本预览下载声明
在.NET框架下使用自定义配置设置(Use the custom configuration settings in the.NET framework)
Use the custom configuration settings in the.NET framework
Release time: 2007-04-30 08:00:00 source: Author: Click: 222
The.NET framework of the XML configuration to make configuration settings based on the familiar. It also provides the necessary means to access these settings through the collection class (Collection, classes).
You can access the actual configuration data through a static ConfigurationSettings class. The class also provides a GetConfig () method that returns an object to a suitable set. In this article, Ill demonstrate three methods that can be used to access and store configuration information.
The application configuration data is stored in the App.config file and defined by the configSections node. Each section has a type property definition. The 3 types Ill discuss here are NameValueSectionHandler, SingleTagSectionHandler, and DictionarySectionHandler. You can define a section group with a sectionGroup element. The following is an example of the configuration section definition:
section name= MyCustomSection
Type= System.Configuration.NameValueSectionHandler /
It is recommended to use type=, System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561Array34e08Array
The section group is an individual configuration section embedded with a sectionGroup element. The following is an example of a set of sections:
sectionGroup, name=, CustomGroup
section name= Custom1
Type= System.Configuration.NameValueSectionHandler /
section, name=, Custom2, type=, System.Configuration.NameValueSectionHandler /
/sectionGroup
Finally, the configuration section you specify will be used to construct custom XML nodes that store configuration data. To add data to the configuration section, simply put the configuration section as a XML node and add the Collection data with the add node. The following example is a NameValueSec
显示全部