开发者

Calling generic method in spring.net application context

开发者 https://www.devze.com 2022-12-22 22:27 出处:网络
I\'m trying to invoke this method in spring.net, but i\'m having trouble getting the configuration right.

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

精彩评论

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

关注公众号