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<Edu3.DTOModel.BinaryAsset.BinaryAssetExtensionDto>"/>
精彩评论