Contextual bindings with Ninject 2.0
Posted
by Przemaas
on Stack Overflow
See other posts from Stack Overflow
or by Przemaas
Published on 2010-03-24T13:14:06Z
Indexed on
2010/05/20
19:40 UTC
Read the original article
Hit count: 283
In Ninject 1.0 I had 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));
First call was resolved to instance of Target1, second call was resolved to instance of Target2.
How to translate this into Ninject 2.0?
© Stack Overflow or respective owner