How is it possible to add entry to dictionary, defined in parent object, from the child object?
*UPDATED I edit my config as follows:
<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>
but, unfortunately, it now throws cast exception:
Cannot convert property value of type [System.Collections.Specialized.HybridDictionary] to required type [System.Collections.Generic.IDictionary`2[[System.String, ],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
I haven't tried this myself, but according to the docs, spring.net will use the
Add
method of the collection to add items, if the collection itself is exposed as a readonly property.So it might be possible to use object definition inheritance to achieve the behavior you describe. Config will be something like:
This will only work if
FieldNameMap
is a readonly property.