Is it possible to set a ninject binding to comply with a general constraint?
For instance:
interface IFoo { } interface IBar { } interface IRepository<T> { } class FooRepository<T> : IRepository<T> where T : IFoo { } class BarRepository<T> : IRepository<T> where T : IBar { } class Foo : IFoo { } class Bar : IBar { } class Program { static void Main(string[] args) { IKernel kernel = new StandardKernel();
Calling this as-is code will exclude several activation paths: -
IRepository activation error {Foo}: several matching bindings are available.
How to configure bindings for conditional value T? Ideally, I would like them to select constraints from the target type, since I already defined them there, but if I have to define them again in a binding, which is also acceptable.
source share