6.1.4: e.g. 6.10 Using the Ninject WithPropertyValue Method

This commit is contained in:
Jason Zhu 2021-08-10 22:55:29 +10:00
parent cbd679abba
commit d597a410d4

View File

@ -13,8 +13,11 @@ namespace NinjectDemo
static void Main(string[] args)
{
IKernel ninjectKernel = new StandardKernel();
ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
ninjectKernel.Bind<IDiscountHelper>().To<DefaultDiscountHelper>();
ninjectKernel.Bind<IValueCalculator>()
.To<LinqValueCalculator>();
ninjectKernel.Bind<IDiscountHelper>()
.To<DefaultDiscountHelper>()
.WithPropertyValue("DiscountSize", 50M);
// get the interface implementation
IValueCalculator calcImp1 = ninjectKernel.Get<IValueCalculator>();