Skip to content

Instantly share code, notes, and snippets.

@garydevenay
Created July 22, 2017 08:16
Show Gist options
  • Save garydevenay/3d5207bc1a9a17311d1dd1e98604231a to your computer and use it in GitHub Desktop.
Save garydevenay/3d5207bc1a9a17311d1dd1e98604231a to your computer and use it in GitHub Desktop.
///
/// 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