public class NinjectControllerFactory : DefaultControllerFactory { //A Ninject "kernet" is the thing that can supply object instances private IKernel kernel = new StandardKernel(new SportsStoreServices()); protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { return (IController)kernel.Get(controllerType); } private class SportsStoreServices : NinjectModule { public string QString = null; public override void Load() { Bind<IProductsRepository>().To<SqlProductsRepository>() .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString); } } }
private class SportsStoreServices : NinjectModule { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)