Created
May 17, 2012 19:46
-
-
Save Aaronontheweb/2721187 to your computer and use it in GitHub Desktop.
Ninject for MVC4 WebApi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is part of the file that is generated automatically when you install Ninject.MVC3 -pre via Nuget */ | |
/// <summary> | |
/// Creates the kernel that will manage your application. | |
/// </summary> | |
/// <returns>The created kernel.</returns> | |
private static IKernel CreateKernel() | |
{ | |
var kernel = new StandardKernel(); | |
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); | |
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); | |
RegisterServices(kernel); | |
//Creates a dependency resolver for Web API controllers specifically | |
var resolver = new NinjectDependencyResolver(kernel); | |
GlobalConfiguration.Configuration.ServiceResolver.SetResolver(resolver.GetService, resolver.GetServices); | |
return kernel; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment