我为App.Config
文件创建了自定义配置部分,现在它看起来像这样:
<mySection>
<myCollection>
<element name="1" />
<element name="2" />
</myCollection>
</mySection>
正如命名所示,我的类继承自ConfigurationSection
(MySection
),ConfigurationElementCollection
(MyCollection
AddItemName="element"
,其属性设为MySection
1}})和ConfigurationElement
。但我想知道如何实现类似于以下的结构:
<mySection>
<myElements>
<element name="1" />
<element name="2" />
<additionalInfo>"..."</additionalInfo>
</myElements>
<someOtherSetting option="blub" />
</mySection>
我仍可以ConfigurationElementCollection
使用MyElements
,还是必须使用其他内容,因为element
标记(由AddItemName="element"
指定{ {1}}类),还有另一个?如果没有,这里使用的课程是什么?
我觉得标签之间的某些内容必须与某个MySection
类的属性相对应,以便它等同于以下内容?
AdditionalInfo
至于<additionalInfo content="..." />
我想我可以添加另一个与someOtherSetting
相对应的属性,但我还没有进行测试。