Ninject 注入泛型接口

This should work:-

Bind(typeof(IRepository<>)).To(typeof(Repository<>));

where:-

IRepository<> is an interface of the form:-

public interface IRepository<T> where T :class 
{

//...

}

Repository<> is a class of the form:-

public class Repository<T>:IRepository<T> where T :class
{

//...

}
posted @ 2013-01-31 08:50  chunchill  阅读(480)  评论(0编辑  收藏  举报