我正在使用Ninject 2.2,我正在尝试为一个带有两个类型参数的开放泛型设置绑定.根据此答案由QES,结合正确的语法IRepository<T>来Repository<T>是这样的:
Bind(typeof(IRepository<>)).To(typeof(Repository<>));
Run Code Online (Sandbox Code Playgroud)
如果IRepository仅使用一个类型参数,则上述语法可以正常工作,但如果需要更多,则会中断(给出Using the generic type 'Repository<T,U>' requires 2 type arguments编译时错误.)
我怎样才能结合IRepository<T,U>到Repository<T,U>?
谢谢.
BFr*_*ree 43
Bind(typeof(IRepository<,>)).To(typeof(Repository<,>));
Run Code Online (Sandbox Code Playgroud)
试试......
| 归档时间: |
|
| 查看次数: |
4377 次 |
| 最近记录: |