Advertisement
gunnim

Untitled

Jul 24th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(UnityActivator), "Start")]
  2. [assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(UnityActivator), "Shutdown")]
  3.  
  4. /// <summary>Provides the bootstrapping for integrating Unity when it is hosted in ASP.NET</summary>
  5. public static class UnityActivator
  6. {
  7.     /// <summary>Integrates Unity when the application starts.</summary>
  8.     public static void Start()
  9.     {
  10.         // This is required if you intend to use the PerRequestLifetimeManager
  11.         Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
  12.     }
  13.  
  14.     /// <summary>Disposes the Unity container when the application is shut down.</summary>
  15.     public static void Shutdown()
  16.     {
  17.         var container = UnityConfig.GetConfiguredContainer();
  18.         container.Dispose();
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement