I'm looking at this tutorial, but not quite understanding how to create a factory that can provide me separate implementations of an interface.
http://stefanoricciardi.com/2011/01/21/ninject-mini-tutorial-part-1/
public class IJob {
...
}
public class JobImpl1 : IJob {
...
}
public class JobImpl2 : IJob {
...
}
using (IKernel kernel = new StandardKernel()) {
kernel.Bind<IJob>().To<JobImpl2>();
var job = kernel.Get<IJob>();
}
My goal is to make a factory class that wraps this Ninject Kernel so I can provide different implementations of my IJob interface depending on whether I'm in a unit test environment vs a live environment. However, I also want to keep the Ninject hidden inside the factory wrapper so that the rest of the code will not depend on Ninject.
There is a separate extension Ninject.Extensions.Factory that allows you to generate Abstract Factory implementation on fly based on interface
Kernel configuration
Resolve Abstract Factory at runtime using kernel
Abstract Factory interface