【发布时间】:2012-12-01 04:42:34
【问题描述】:
我想在我的 web.config 中有一个自定义部分,如下所示:
<MyMainSection attributeForMainSection = "value foo">
<add name = "foo"
type = "The.System.Type.Of.Foo, Assembly, Qualified Name Type Name" />
<add name = "bar"
type = "The.System.Type.Of.Bar, Assembly, Qualified Name Type Name" />
</MyMainSection>
我已经定义了以下代码:
using System.Configuration;
class MyMainSection : ConfigurationSection
{
/*I've provided custom implemenation.
Not including it here for the sake of brevity. */
[ConfigurationProperty("attributeForMainSection")]
public string AttributeForMyMainSection { get; set; }
[ConfigurationProperty("add")]
public AddElement TheAddElement { get; set; }
private class AddElement: ConfigurationElement
{
/* Implementation done */
}
}
如果我想允许多个添加元素,这个属性 TheAddElement 应该是 IEnumerable<AddElement> 还是只是 AddElement?
【问题讨论】:
-
你真的应该重命名你的问题,根据你的实际问题,这很容易产生误导。
标签: c# configuration web-config app-config