C# ConfigurationElementCollection对象能否为其元素包含另一个ConfigurationElementCollection对象?
ConfigurationElementCollection对象能否为其元素包含另一个ConfigurationElementCollection对象 我有一个xml,其中testsection是节根:C# ConfigurationElementCollection对象能否为其元素包含另一个ConfigurationElementCollection对象?,c#,configuration,.net-2.0,web-config,app-config,C#,Configuration,.net 2.0,Web Config,App Config,ConfigurationElementCollection对象能否为其元素包含另一个ConfigurationElementCollection对象 我有一个xml,其中testsection是节根: <testsection> <head> <metaData> <metaGroup id="general"> <meta name="Content-type
<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>
是否可以使用ConfigurationSection、ConfigurationElement和ConfigurationElementCollection创建可以读取上述xml的类
问题是,当我们实现ConfigurationElementCollection时,我们不能定义集合中的元素属于另一个ConfigurationElementCollection类型
如果配置部分是这样的(没有元组元素),我可以让它工作:
我认为只有ConfigurationElement对象才能包含ConfigurationElementCollection对象(ConfigurationElementCollection必须为其父ConfigurationElement指定一个对象)。所以我认为,如果元组是ConfigurationElement,并且如果我添加一个新的ConfigurationElementCollection(元组集合)作为元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>
我认为只有ConfigurationElement对象才能包含ConfigurationElementCollection对象(ConfigurationElementCollection必须为其父ConfigurationElement指定一个对象)。所以我认为,如果元组是ConfigurationElement,并且如果我添加一个新的ConfigurationElementCollection(元组集合)作为元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>