在Spring.NET中将类的类型作为值传递

Lie*_*oen 1 .net spring.net

有没有办法将类型作为Spring.NET中的值传递?

我的字典看起来像这样:

private Dictionary<int, Type> ContentItemTypes { get; set; }
Run Code Online (Sandbox Code Playgroud)

在代码中我将初始化为:

registry.addContentItemType(0, typeof(ContentItem));
Run Code Online (Sandbox Code Playgroud)

你是如何在Spring.NET中做到这一点的.到目前为止我有这个:

<object id="ContentItemTypeRegistry"
      type="Edu3.DomainModel.Framework.Model.Registry.ContentItemTypeRegistry, Edu3.DomainModel.Framework"
      factory-method="GetInstance">
  <property name="ContentItemTypes">
    <dictionary key-type="int" value-type="System.Type">
      <entry key="0">
        <value type="System.Type">Edu3.DomainModel.Framework.Model.ContentItem</value>
      </entry>
    </dictionary>
  </property>
</object>
Run Code Online (Sandbox Code Playgroud)

它是否正确?

Ben*_*nyM 5

甚至更短.

<object id="ContentItemTypeRegistry"
 type="Edu3.DomainModel.Framework.Model.Registry.ContentItemTypeRegistry, Edu3.DomainModel.Framework"
 factory-method="GetInstance">
    <property name="ContentItemTypes">
      <dictionary key-type="int" value-type="System.Type">
        <entry key="0" expression="T(Edu3.DomainModel.Framework.Model.ContentItem)" ></entry>
      </dictionary>
    </property>
  </object>
Run Code Online (Sandbox Code Playgroud)