32 lines
811 B
C#
32 lines
811 B
C#
|
using Ninject;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Web;
|
|||
|
using System.Web.Mvc;
|
|||
|
using System.Web.Routing;
|
|||
|
|
|||
|
namespace SportsStore.WebUI.Infrastructure
|
|||
|
{
|
|||
|
public class NinjectControllerFactory : DefaultControllerFactory
|
|||
|
{
|
|||
|
private IKernel ninjectKernel;
|
|||
|
|
|||
|
public NinjectControllerFactory()
|
|||
|
{
|
|||
|
ninjectKernel = new StandardKernel();
|
|||
|
AddBindings();
|
|||
|
}
|
|||
|
|
|||
|
protected override IController GetControllerInstance(RequestContext requestContext,
|
|||
|
Type controllerType)
|
|||
|
{
|
|||
|
return controllerType == null ? null : (IController)ninjectKernel.Get(controllerType);
|
|||
|
}
|
|||
|
|
|||
|
private void AddBindings()
|
|||
|
{
|
|||
|
// put additional bindings here
|
|||
|
}
|
|||
|
}
|
|||
|
}
|