I'm using Ninject 2.2, and I'm trying to setup a binding for an open generic that takes two type arguments. According to this answer by qes, the correct syntax to bind IRepository<T> to Repository<T> is this:
Bind(typeof(IRepository<>)开发者_开发技巧).To(typeof(Repository<>));
The above syntax works perfectly if IRepository takes just one type argument, but breaks if it takes more (gives a Using the generic type 'Repository<T,U>' requires 2 type arguments compile time error.)
How can I bind IRepository<T,U> to Repository<T,U>?
Thanks.
Bind(typeof(IRepository<,>)).To(typeof(Repository<,>));
Try that....
加载中,请稍侯......
精彩评论