开发者

Calling generic method in spring.net application context

I'm trying to invoke this method in spring.net, but i'm having trouble getting the configuration right.

Method:

public void AddRepository<TEntity>(IRepository<TEntity> repository)
   where TEntity : IEntity
{
开发者_运维知识库   Repositories.Add(repository.GetType().Name, repository);
}

Config:

<object type="Spring.Objects.Factory.Config.MethodInvokingFactoryObject, Spring.Core">
    <property name="TargetObject">
      <ref local="RepositoryFactory" />
    </property>
    <property name="TargetMethod" value="AddRepository"/>
    <property name="Arguments">
      <list>
        <ref object="BinaryAssetFileRepository"/>
      </list>
    </property>
  </object>

Is it possible to address generic methods in this way?


The OP wrote:

In the meanwhile I found the problem. The type parameter can be passed with the method name in the TargetMethod property:

<property name="TargetMethod" value="AddRepository&lt;Edu3.DTOModel.BinaryAsset.BinaryAssetExtensionDto>"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜