如何创建和填充字典<字符串,对象>采用统一的XML配置?字符串、字典、对象、XML

由网友(拥抱好吗让我踏实)分享简介:如何创建并使用统一的XML配置填充字典?How do I create and populate a Dictionary using Unity's xml configuration?我需要使用统一的依赖引用创建一个词典并填充对象。I need to create a Dictionary and popul...

如何创建并使用统一的XML配置填充字典?

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.

我怎样才能做到这一点?

How can I accomplish this?

推荐答案

本作品

<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>
阅读全文

相关推荐

最新文章