Created
July 22, 2017 08:16
-
-
Save garydevenay/3d5207bc1a9a17311d1dd1e98604231a to your computer and use it in GitHub Desktop.
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
/// | |
/// I usually create an UmbracoBooter class to set the dependency resolver and config | |
/// | |
public class UmbracoBooter : IApplicationEventHandler | |
{ | |
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
var kernel = NinjectWebCommon.UmbracoStart(); | |
DependencyResolver.SetResolver(new Ninject.Web.Mvc.NinjectDependencyResolver(kernel)); | |
GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new UmbracoWebApiHttpControllerActivator(kernel)); | |
} | |
} | |
/// | |
/// Use this method to get the kernel from Ninject | |
/// | |
public static class NinjectWebCommon | |
{ | |
public static IKernel UmbracoStart() | |
{ | |
bootstrapper.Initialize(CreateKernel); | |
return bootstrapper.Kernel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment