6.1.4 Specifying Property and Parameter Values: e.g. 6.12 Binding to a Class that Requires a Constructor Parameter
parent
390cf4555c
commit
ebb1840db9
|
@ -17,7 +17,7 @@ namespace NinjectDemo
|
||||||
.To<LinqValueCalculator>();
|
.To<LinqValueCalculator>();
|
||||||
ninjectKernel.Bind<IDiscountHelper>()
|
ninjectKernel.Bind<IDiscountHelper>()
|
||||||
.To<DefaultDiscountHelper>()
|
.To<DefaultDiscountHelper>()
|
||||||
.WithPropertyValue("DiscountSize", 50M);
|
.WithConstructorArgument("discounttParam", 50M);
|
||||||
|
|
||||||
// get the interface implementation
|
// get the interface implementation
|
||||||
IValueCalculator calcImp1 = ninjectKernel.Get<IValueCalculator>();
|
IValueCalculator calcImp1 = ninjectKernel.Get<IValueCalculator>();
|
||||||
|
|
Loading…
Reference in New Issue