通过上面的代码我们可以看出不同的type通过GetConfig返回的类型不同具体获得配置内容的方式也不一样 配置节处理程序
返回类型
SingleTagSectionHandler
SystemsCollectionsIDictionary
DictionarySectionHandler
SystemsCollectionsIDictionary
NameValueSectionHandler
SystemsCollectionsSpecializedNameValueCollection
自定义配置节组
配置节组是使用<sectionGroup>元素将类似的配置节分到同一个组中配置节组声明 部分将创建配置节的包含元素在<configSections>元素中声明配置节组并将属于该组的节置于< sectionGroup>元素中下面是一个包含配置节组的配置文件的例子
<?xml version=
encoding=
utf
?>
<configuration>
<configSections>
<sectionGroup name=TestGroup>
<section name=Test type=SystemConfigurationNameValueSectionHandler/>
</sectionGroup>
</configSections>
<TestGroup>
<Test>
<add key=Hello value=World/>
</Test>
</TestGroup>
</configuration>
下面是访问这个配置节组的代码
NameValueCollection nc=(NameValueCollection)ConfigurationSettings
GetConfig(
TestGroup/Test
);
MessageBoxShow(ncAllKeys[]ToString()+ +nc[Hello]); //输出Hello World
[] [] []