Guest User

Untitled

a guest
Jul 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. [assembly: WebActivator.PreApplicationStartMethod(typeof(Web.App_Start.NinjectMVC3), "Start")]
  2. [assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(Web.App_Start.NinjectMVC3), "Stop")]
  3.  
  4. namespace Web.App_Start
  5. {
  6. public static class NinjectMVC3
  7. {
  8. private static readonly Bootstrapper bootstrapper = new Bootstrapper();
  9.  
  10. /// <summary>
  11. /// Starts the application
  12. /// </summary>
  13. public static void Start()
  14. {
  15. DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
  16. bootstrapper.Initialize(CreateKernel);
  17. }
  18.  
  19. /// <summary>
  20. /// Stops the application.
  21. /// </summary>
  22. public static void Stop()
  23. {
  24. bootstrapper.ShutDown();
  25. }
  26.  
  27. /// <summary>
  28. /// Creates the kernel that will manage your application.
  29. /// </summary>
  30. /// <returns>The created kernel.</returns>
  31. private static IKernel CreateKernel()
  32. {
  33. var kernel = Container;
  34. RegisterServices(kernel);
  35. return kernel;
  36. }
  37.  
  38. private static IKernel _Container = null;
  39. public static IKernel Container
  40. {
  41. get
  42. {
  43. if (_Container == null)
  44. _Container = new StandardKernel();
  45. return _Container;
  46. }
  47.  
  48. }
  49.  
  50.  
  51. /// <summary>
  52. /// Load your modules or register your services here!
  53. /// </summary>
  54. /// <param name="kernel">The kernel.</param>
  55. private static void RegisterServices(IKernel kernel)
  56. {
  57. kernel.Bind<ITempDataProvider>().To<CookieTempDataProvider>();
  58. }
  59.  
  60.  
  61. }
  62. }
  63.  
  64. [SessionState(SessionStateBehavior.Disabled)]
Add Comment
Please, Sign In to add comment