Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, configuring this in xml isn't pretty, consider switching to Spring.Net code config to <a href="http://www.springframework.net/codeconfig/refdoc/migration-example.html#d4e73" rel="nofollow noreferrer">configure your spring context in C#</a>.</p> <p>Anyway, to do this in xml, you use the constructors of the generic .net collections. For instance, <code>List&lt;T&gt;</code> takes an <code>IList&lt;T&gt;</code> constructor, so you can configure a list of strings as follows:</p> <pre class="lang-xml prettyprint-override"><code>&lt;object id="list1" type="System.Collections.Generic.List&amp;lt;string&gt;"&gt; &lt;constructor-arg&gt; &lt;list element-type="string"&gt; &lt;value&gt;abc&lt;/value&gt; &lt;value&gt;def&lt;/value&gt; &lt;/list&gt; &lt;/constructor-arg&gt; &lt;/object&gt; </code></pre> <p>Note that in xml you have to use <code>&amp;lt;</code>, because using <code>&lt;</code> isn't legal xml. Setting generic collection values is discussed <a href="http://www.springframework.net/doc-latest/reference/html/objects.html#objects-generic-collections-values" rel="nofollow noreferrer">in the Spring.net docs</a>.</p> <p>A generic <code>Dictionary&lt;string, System.Collections.Generic.List&lt;string&gt;&gt;</code> can be configured in a similar manner, which is also discussed in <a href="https://stackoverflow.com/a/5147812/322283">this answer</a>:</p> <pre class="lang-xml prettyprint-override"><code>&lt;object id="dic1" type="System.Collections.Generic.Dictionary&amp;lt;string, System.Collections.Generic.List&amp;lt;string&gt;&gt;"&gt; &lt;constructor-arg&gt; &lt;dictionary key-type="string" value-type="System.Collections.Generic.List&amp;lt;string&gt;"&gt; &lt;entry key="keyToList1" value-ref="list1" /&gt; &lt;entry key="keyToList2" value-ref="list2" /&gt; &lt;/dictionary&gt; &lt;/constructor-arg&gt; &lt;/object&gt; </code></pre> <p>And you probably see the next one coming now:</p> <pre class="lang-xml prettyprint-override"><code>&lt;object id="dic0" type="System.Collections.Generic.Dictionary&amp;lt;string, System.Collections.Generic.Dictionary&amp;lt;string, System.Collections.Generic.List&amp;lt;string&gt;&gt;&gt;"&gt; &lt;constructor-arg&gt; &lt;dictionary key-type="string" value-type="System.Collections.Generic.Dictionary&amp;lt;string, System.Collections.Generic.List&amp;lt;string&gt;&gt;"&gt; &lt;entry key="keyToDic1 " value-ref="dic1" /&gt; &lt;/dictionary&gt; &lt;/constructor-arg&gt; &lt;/object&gt; </code></pre> <p>Which can be injected:</p> <pre class="lang-xml prettyprint-override"><code>&lt;object id="MyObject" type="MyNamespace.MyClass, MyAssembly"&gt; &lt;property name="ContextMenuModel" ref="dic0" /&gt; &lt;/object&gt; </code></pre> <p>This isn't really pretty, but you can slightly <a href="http://www.springframework.net/doc-latest/reference/html/objects.html#objects-creation-generic-types" rel="nofollow noreferrer">improve the readability of your xml using type aliases</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload