Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [assembly: WebActivator.PreApplicationStartMethod(typeof(Web.App_Start.NinjectMVC3), "Start")]
- [assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(Web.App_Start.NinjectMVC3), "Stop")]
- namespace Web.App_Start
- {
- public static class NinjectMVC3
- {
- private static readonly Bootstrapper bootstrapper = new Bootstrapper();
- /// <summary>
- /// Starts the application
- /// </summary>
- public static void Start()
- {
- DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
- bootstrapper.Initialize(CreateKernel);
- }
- /// <summary>
- /// Stops the application.
- /// </summary>
- public static void Stop()
- {
- bootstrapper.ShutDown();
- }
- /// <summary>
- /// Creates the kernel that will manage your application.
- /// </summary>
- /// <returns>The created kernel.</returns>
- private static IKernel CreateKernel()
- {
- var kernel = Container;
- RegisterServices(kernel);
- return kernel;
- }
- private static IKernel _Container = null;
- public static IKernel Container
- {
- get
- {
- if (_Container == null)
- _Container = new StandardKernel();
- return _Container;
- }
- }
- /// <summary>
- /// Load your modules or register your services here!
- /// </summary>
- /// <param name="kernel">The kernel.</param>
- private static void RegisterServices(IKernel kernel)
- {
- kernel.Bind<ITempDataProvider>().To<CookieTempDataProvider>();
- }
- }
- }
- [SessionState(SessionStateBehavior.Disabled)]
Add Comment
Please, Sign In to add comment