[英]Can ConfigurationElementCollection object contain for its elements another ConfigurationElementCollection objects?
Can ConfigurationElementCollection object contain for its elements another ConfigurationElementCollection objects? ConfigurationElementCollection对象是否可以为其元素包含另一个ConfigurationElementCollection对象?
I have this xml where testsection is section root: 我有此xml,其中testsection是节根:
<testsection>
<head>
<metaData>
<metaGroup id="general">
<meta name="Content-type" content="text/html; charset=utf-8" type="http-equiv" />
</metaGroup>
<metaGroup id="default">
<meta name="something" content="test" type="name" />
</metaGroup>
</metaData>
</head>
</testsection>
Is it possible to create classes with ConfigurationSection, ConfigurationElement and ConfigurationElementCollection that can read above xml? 是否可以使用可以读取以上xml的ConfigurationSection,ConfigurationElement和ConfigurationElementCollection创建类?
The problem is that when we are implementing ConfigurationElementCollection we can't define that element in collection is of type another ConfigurationElementCollection. 问题在于,当我们实现ConfigurationElementCollection时,我们无法定义集合中的元素为另一个ConfigurationElementCollection类型。
I can make it to work if configuration section is like this (without metaGroup elements): 如果配置部分是这样的(没有metaGroup元素),我可以使其工作:
<testsection>
<head>
<metaData>
<meta name="Content-type" content="text/html; charset=utf-8" type="http-equiv" />
<meta name="something" content="test" type="name" />
</metaData>
</head>
</testsection>
I think that only ConfigurationElement objects can contain ConfigurationElementCollection objects (ConfigurationElementCollection must have for its parent ConfigurationElement). 我认为只有ConfigurationElement对象可以包含ConfigurationElementCollection对象(ConfigurationElementCollection必须为其父ConfigurationElement具有)。 So I think that I can solve this problem if metaGroup would be ConfigurationElement and if I add a new ConfigurationElementCollection (metaGroupCollection) as parent of meta ConfigurationElement. 因此,我认为如果metaGroup将为ConfigurationElement并添加新的ConfigurationElementCollection(metaGroupCollection)作为meta ConfigurationElement的父级,则可以解决此问题。
<testsection>
<head>
<metaData>
<metaGroup id="general">
<metaGroupCollection>
<meta name="Content-type" content="text/html; charset=utf-8" type="http-equiv" />
</metaGroupCollection>
</metaGroup>
<metaGroup id="default">
<metaGroupCollection>
<meta name="something" content="test" type="name" />
</metaGroupCollection>
</metaGroup>
</metaData>
</head>
</testsection>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.