我为我的App.Config文件创建了一个自定义配置部分,现在它看起来像这样:
<mySection>
<myCollection>
<element name="1" />
<element name="2" />
</myCollection>
</mySection>
正如命名所暗示的,我的类继承自ConfigurationSection( MySection)、ConfigurationElementCollection(在 的属性中设置了MyCollection)和. 但我想知道如何实现类似于以下的结构:AddItemName="element"MySectionConfigurationElement
<mySection>
<myElements>
<element name="1" />
<element name="2" />
<additionalInfo>"..."</additionalInfo>
</myElements>
<someOtherSetting option="blub" />
</mySection>
我还能使用ConfigurationElementCollectionforMyElements还是必须使用其他东西,因为不仅有element标签(AddItemName="element"在MySection类中指定),还有另一个标签?如果不是,这里使用什么类?
而且我想在标签之间有一些东西必须只对应于某个AdditionalInfo类的属性,这样它就相当于以下内容?
<additionalInfo content="..." />
至于someOtherSetting我想我可以添加另一个属性来MySection对应这个,但我还没有开始测试它。