.net ConfigurationElementCollection中的多个ConfigurationElement类型
我希望有一个如下所示的配置部分:.net ConfigurationElementCollection中的多个ConfigurationElement类型,.net,app-config,.net,App Config,我希望有一个如下所示的配置部分: <mycollection> <add name="myelement" type="class, assembly" var1="value" var2="value" /> <add name="myelement2" type="class2, assembly" var1="value" var3="value" var4="value" /> </mycollection> 这似乎更容易实现,但会导
<mycollection>
<add name="myelement" type="class, assembly" var1="value" var2="value" />
<add name="myelement2" type="class2, assembly" var1="value" var3="value" var4="value" />
</mycollection>
这似乎更容易实现,但会导致更详细的配置文件
第一个选项是关于.NET配置模式的吗?第二个选项是可能的吗?您可以做的其他事情是覆盖。通过这种方式,您可以创建如下参数配置元素:
<parameters>
<string name="Patrick Huizinga" />
<string country="the Netherlands" />
<int currentScore="206" />
</parameters>
OnDeserializedElement接受一个可以查询自定义元素属性的参数。通过使用(您可以从中获得)您甚至可以无需任何额外的努力就支持DateTime和Uri之类的类型。是的,这是可能的!有关详细信息,请参阅本文:按照同样的思路,这里有一个解决方案,允许您使用IConfigurationSectionHandler读取极其灵活的xml:[
<parameters>
<string name="Patrick Huizinga" />
<string country="the Netherlands" />
<int currentScore="206" />
</parameters>