【发布时间】:2011-10-08 03:11:07
【问题描述】:
我正在使用 Ninject 2.2,并且我正在尝试为一个开放的泛型设置一个绑定,该泛型采用两个类型参数。根据qes的answer,将IRepository<T>绑定到Repository<T>的正确语法是这样的:
Bind(typeof(IRepository<>)).To(typeof(Repository<>));
如果IRepository 只接受一个类型参数,则上述语法完美运行,但如果需要更多则中断(给出Using the generic type 'Repository<T,U>' requires 2 type arguments 编译时错误。)
如何将IRepository<T,U> 绑定到Repository<T,U>?
谢谢。
【问题讨论】: