【发布时间】:2013-09-09 04:17:15
【问题描述】:
如何从子对象添加条目到在父对象中定义的字典?
*更新 我编辑我的配置如下:
<object id="ParentType" singleton="false" type="SomeType">
<property name="FieldNameMap">
<dictionary key-type="string" value-type="string" >
<entry key="Title" value="TitleName"/>
</dictionary>
</property>
</object>
<object id="ChildType" singleton="false" type="SomeType" parent="ParentType">
<property name="FieldNameMap">
<dictionary merge="true">
<!-- this entry should be added to, not replace the whole Dictionary -->
<entry key="Position" value="PositionName"/>
</dictionary>
</property>
</object>
但是,不幸的是,它现在抛出异常:
无法转换类型的属性值 [System.Collections.Specialized.HybridDictionary] 到所需类型 [System.Collections.Generic.IDictionary`2[[System.String, ],[System.String,mscorlib,版本=4.0.0.0,文化=中性, PublicKeyToken=b77a5c561934e089]]
【问题讨论】:
-
我尝试在子字典中指定
key-type和value-type,结果相同
标签: spring configuration configuration-files spring.net