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
?