In Ninject 1.0, I had the following binding definitions:
Bind<ITarget>().To<Target1>().Only(When.Context.Variable("variable").EqualTo(true)); Bind<ITarget>().To<Target2>();
Given such bindings, I had calls:
ITarget target = kernel.Get<ITarget>(With.Parameters.ContextVariable("variable", true)); ITarget target = kernel.Get<ITarget>(With.Parameters.ContextVariable("variable", false));
The first call was allowed to an instance of Target1, the second call was allowed to an instance of Target2.
How to translate this to Ninject 2.0?
parameters ninject ninject-2
Przemaas
source share