I have been using Ninject for a short time, and I'm trying to figure out how to do something that I did in Unity with the entries app.config / web.config.
I am sure that this is simple, just did not find the best way to implement it, and, of course, Ninject does not have the largest documentation.
I want to have different implementations for the interface, without changing the code - a specific application knows which implementation to use.
For example, when I used Unity, I would have a live application and a unit test library using different data libraries. So:
var repo = IoC.Get<IRepository>();
will return RealRepository in my live application and FakeRepository in my unit tests. I would just map the classes in my app.config or web.config.
In Ninject, since you define mappings in the code, there is no way to decide which implementations (or which module) you use, with the exception of the code, but of course, the whole purpose - I want to specifically indicate which implementation I want to use.
Is there a good way to do this? The only way I can imagine is to dynamically select the NinjectModule implementation from the configuration file, but that is simply not the case.
source share