6.1.4 Specifying Property and Parameter Values: e.g. 6.12 Binding to a Class that Requires a Constructor Parameter

chap6
Jason Zhu 2021-08-10 23:00:54 +10:00
parent 390cf4555c
commit ebb1840db9
1 changed files with 1 additions and 1 deletions

View File

@ -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>();