【发布时间】:2014-05-02 14:47:20
【问题描述】:
考虑:
行:
<section name="unity" />
方块:
<unity>
<typeAliases />
<containers />
</unity>
假设在缺少块时该行在 .config 文件中可用。
如何以编程方式检查块是否存在?
[编辑]
对于那些很快将问题标记为否定的天才:
我已经试过ConfigurationManager.GetSection()
和
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var section = config.GetSection("unity");
var sInfo = section.SectionInformation;
var isDeclared = sInfo.IsDeclared;
如果我弄错了,请纠正我,如果定义了 <configSections>(即使缺少实际的统一块),上述 not 是否会返回 null。
【问题讨论】: