2021-09-08 10:17:19 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-09-22 15:01:30 +10:00
|
|
|
|
using System.Configuration;
|
2021-09-08 10:17:19 +10:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using System.Web.Services.Description;
|
2021-09-08 10:37:38 +10:00
|
|
|
|
using Moq;
|
2021-09-08 10:17:19 +10:00
|
|
|
|
using Ninject;
|
2021-09-08 10:37:38 +10:00
|
|
|
|
using SportsStore.Domain.Abstract;
|
2021-09-08 13:26:56 +10:00
|
|
|
|
using SportsStore.Domain.Concrete;
|
2021-09-08 10:37:38 +10:00
|
|
|
|
using SportsStore.Domain.Entities;
|
2021-09-08 10:17:19 +10:00
|
|
|
|
|
|
|
|
|
namespace SportsStore.WebUI.Infrastructure
|
|
|
|
|
{
|
|
|
|
|
public class NinjectDependencyResolver : IDependencyResolver
|
|
|
|
|
{
|
|
|
|
|
private IKernel kernel;
|
|
|
|
|
|
|
|
|
|
public NinjectDependencyResolver(IKernel kernelParam)
|
|
|
|
|
{
|
|
|
|
|
kernel = kernelParam;
|
|
|
|
|
AddBindings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object GetService(Type serviceType)
|
|
|
|
|
{
|
|
|
|
|
return kernel.TryGet(serviceType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<object> GetServices(Type serviceType)
|
|
|
|
|
{
|
|
|
|
|
return kernel.GetAll(serviceType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddBindings()
|
|
|
|
|
{
|
2021-09-08 13:26:56 +10:00
|
|
|
|
kernel.Bind<IProductRepository>().To<EFProductRepository>();
|
2021-09-08 10:17:19 +10:00
|
|
|
|
|
2021-09-22 15:01:30 +10:00
|
|
|
|
EmailSettings emailSettings = new EmailSettings
|
|
|
|
|
{
|
|
|
|
|
WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")
|
|
|
|
|
};
|
2021-09-08 10:17:19 +10:00
|
|
|
|
|
2021-09-22 15:01:30 +10:00
|
|
|
|
kernel.Bind<IOrderProcessor>().To<EmailOrderProcessor>()
|
|
|
|
|
.WithConstructorArgument("settings", emailSettings);
|
|
|
|
|
}
|
2021-09-08 10:17:19 +10:00
|
|
|
|
}
|
|
|
|
|
}
|