Search code examples
c#dependency-injectioninversion-of-controlninject

Ninject get target type from IBinding


I have an Interface that is implemented by several types. But before I do a kernel.GetAll<IAmServiceable>() I want to be able to ponder the target types of the injection.

I know the function kernel.GetBindings(typeof(IAmServiceable)) exists but this returns a list of IBinding's.

Does anyone know how I can get the target type from the IBinding?

I want to know the type that is bound to IAmServiceable before it gets instantiated.


Solution

  • This is not possible. E.g what is the type In this case?

    Bind<IX>().ToMethod(c => RandomBool() ? new Foo() : new Bar());