How do I create and populate a Dictionary using Unity\'s xml configuration?
I need to create a Dictionary and populate the objects using dependency references in unity.<
You would have to create some sort of parsing system.
You can use the XML system in .Net to parse the XML code and then add it to the dictionary by doing dictionary.Add();
This works
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<alias alias="MyStuffObject" type="MyStuffObject, MyStuff"/>
<!-- dictionary stuff -->
<alias alias="IDictionaryOfStuff" type="System.Collections.Generic.IDictionary`2[[System.String, mscorlib],[MyStuffObject, MyStuff]], mscorlib"/>
<alias alias="DictionaryOfStuff" type="System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[MyStuffObject, MyStuff]], mscorlib"/>
<!-- Containers -->
<container name="Stuff">
<register type="IDictionaryOfStuff" mapTo="DictionaryOfStuff" name="dictionaryOfStuff">
<constructor />
<method name="Add">
<param name="key" type="System.String" value="Cool_Key"/>
<param name="value" type="IClinicalDocumentParser" dependencyName="coolStuffObject"/>
</method>
</register>
<register type="MyStuffObject" mapTo="MyStuffObject" name="coolStuffObject" />
</container>
</unity>