我正在构建一个自定义ConfigurationSection,以便在演示应用程序中使用。我给继承自ConfigurationSection的类的名称是应用程序在配置文件中查找的部分名称。如何更改此行为?
这是继承自ConfigurationSection
的类的骨架:
public class LongNameBecauseItsTheResultOfFollowingAnOtherwiseGoodConvention: ConfigurationSection
{
...
}
在app.config
文件中,它希望看到以下部分:
<LongNameBecauseItsTheResultOfFollowingAnOtherwiseGoodConvention>
...
</LongNameBecauseItsTheResultOfFollowingAnOtherwiseGoodConvention>
如何在app.config
中使用较短的部分名称,但在源代码中遵循我们的约定?
答案 0 :(得分:1)
在ConfigurationSection
文件的<configSections>
元素中定义app.config
时,您可以指定其他名称。
<configuration>
<configSections>
<section name="ABC123" type="namespaceName.className, assemblyName"/>
</configSections>
</configuration>