2012-01-25 9 views
1

私はNinject DIコンテナを使用しています。そして、私はその後2ジェネリック型を制約でバインドする方法

public interface IRepository<T> where T : AbstractEntity<T>, IAggregateRoot 
{ 
    // methods signatures 
} 

public class Repository<T> : IRepository<T> where T : AbstractEntity<T>, IAggregateRoot 
{ 
    // implementations 
} 

を持っている私は、this.Bind<IRepository<>>().To<Repository<>>();を文として認識されていない別のモジュール

public class DataAccessModule : Ninject.Modules.NinjectModule 
{ 
    public override void Load() 
    { 
     this.Bind<IRepository<>>().To<Repository<>>(); 
    } 
} 

でそれらをバインドしようとしています。

バインドを行うにはどうすればよいですか?

+0

可能複製(http://stackoverflow.com/questions/2216127/ninject-with-generic-interface) – nawfal

答えて

5

この部分をスニークしたhereです。それは彼らのために働いていたように見える:

Bind(typeof(IRepository<>)).To(typeof(Repository<>)); 
[一般的なインターフェースを備えたNInject]の
関連する問題