9.3.4 Registering the Implementation; Listing 9-16 Adding Ninject Bindings for IOrderProcessor to the NinjectDependencyResolver.cs File

chap09
Jason Zhu 2021-09-22 15:01:30 +10:00
parent 27f0d26168
commit ca3c72f560
1 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@ -35,8 +36,14 @@ namespace SportsStore.WebUI.Infrastructure
private void AddBindings()
{
kernel.Bind<IProductRepository>().To<EFProductRepository>();
EmailSettings emailSettings = new EmailSettings
{
WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")
};
kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>()
.WithConstructorArgument("settings", emailSettings);
}
}
}