除了解析类之外,是否有强类型的类或方法可以直接以编程方式访问configuration/configSections元素?
这是定义配置节和组的主要配置区域。我仔细阅读了System.Configuration.ConfigurationSection inheritance的MSDN文档,什么也没有弹出。
System.Configuration.ConfigurationManager类似乎只访问文件的解析版本,并且它似乎不提供对configuration/configSections本身的直接访问。
如果我必须使用XML类解析配置,我并不介意,但如果庞大的FCL还没有一个帮助器来完成这项任务,我会感到惊讶。
configSections部分的示例(也请参阅其中的我的注释):
<?xml version="1.0"?>
<configuration>
<!-- This element is what I want to directly access programmatically -->
<configSections>
<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler,dotless.Core" />
<section name="zforms" type="ZForms.Config.ZFormsSection, ZFormsLib"/>
</configSections>
<!-- I don't care about this -->
<zforms default="form2">
<add name="form1" title="Reading" />
<add name="form2" title="Assignment" />
</zforms>发布于 2011-08-09 04:32:47
查看ConfigurationManager class和GetSection method。
https://stackoverflow.com/questions/6988155
复制相似问题