lex*_*eme 1 c# generics ninject
我正在使用Ninject
DI容器.我有两个
public interface IRepository<T> where T : AbstractEntity<T>, IAggregateRoot
{
// methods signatures
}
public class Repository<T> : IRepository<T> where T : AbstractEntity<T>, IAggregateRoot
{
// implementations
}
Run Code Online (Sandbox Code Playgroud)
然后我试图将它们绑定在一个单独的模块中
public class DataAccessModule : Ninject.Modules.NinjectModule
{
public override void Load()
{
this.Bind<IRepository<>>().To<Repository<>>();
}
}
Run Code Online (Sandbox Code Playgroud)
哪里this.Bind<IRepository<>>().To<Repository<>>();
不被承认为陈述.
如何进行绑定?
从这里抓住这件作品.看起来它对他们有用:
Bind(typeof(IRepository<>)).To(typeof(Repository<>));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
140 次 |
最近记录: |