7
I는 다음의 클래스 가지고Ninject에 여러
가using System;
interface IA { }
class A1 : IA { }
class A2 : IA { }
class B
{
public B(IA a) {}
}
class BProvider : Provider<B>
{
IA _a;
public BProvider(IA a) { _a=a; }
protected override B CreateInstance(IContext context) { return new B(_a); }
}
Ninject에 모듈로드() 코드 :
가Bind<IA>().To<A1>();
Bind<IA>().To<A2>();
Bind<B>().ToProvider<BProvider>();
메인 코드 :
kernel.GetAll<IA>(); // works fine
kernel.GetAll<B>(); // I expect to get IEnumerable<B> with two elements, but instead of this I get an error that there are multiple bindings of IA and ninject cannot determine which to use
그래서 질문이다 마지막 문장을 예상대로 작동 시키거나 다른 방법으로 할 수 있습니까?