Castle windsor:注册多个项目的仿制药
本文关键字:项目 windsor 注册 Castle | 更新日期: 2023-09-27 18:27:42
我有一个像这样定义的通用接口-
public interface IGenericRepository<TEntity, TDbContextType>
where TEntity : class
where TDbContextType : IDbContextType
这个接口是由一个类似的类实现的
public class GenericRepository<TEntity,TDbContextType>
: IGenericRepository<TEntity, TDbContextType>
where TEntity : class
where TDbContextType: IDbContextType
我试着用castle-注册这个接口和实现
_container.Register(Component.For(typeof (IGenericRepository<>))
.ImplementedBy(typeof (GenericRepository<>))
.LifestylePerWcfOperation());
但它在编译时失败,说"参数数量不正确"。
它无法编译,因为您用一个参数指定了泛型类型,但用两个参数定义了类型。
因此,应该使用IGenericRepository<,>
和GenericRepository<,>
,而不是IGenericRepository<>
和GenericRepository<>
。