Ejemplo n.º 1
0
 public void Init(HttpApplication context)
 {
     context.BeginRequest += (sender, e) => StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
     context.EndRequest   += (sender, e) => {
         HttpContextLifecycle.DisposeAndClearAll();
         StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
     };
 }
Ejemplo n.º 2
0
        private void OnContextOnEndRequest(object sender, EventArgs e)
        {
            foreach (var task in
                     StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer.GetAllInstances <IRunAfterEachRequest>())
            {
                task.Execute();
            }

            HttpContextLifecycle.DisposeAndClearAll();
            StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
        }
 public void Init(HttpApplication context)
 {
     context.BeginRequest += (sender, e) => StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
     context.EndRequest   += (sender, e) =>
     {
         var unit = DependencyResolver.Current.GetService <IUnitOfWork>();
         unit.Commit();
         HttpContextLifecycle.DisposeAndClearAll();
         StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
     };
 }
Ejemplo n.º 4
0
 public void Init(HttpApplication context)
 {
     context.BeginRequest += (sender, e) =>
     {
         StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
         var serviceLocatorProvider = new ServiceLocatorProvider(() => StructuremapMvc.StructureMapDependencyScope);
         StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer.Configure(cfg => cfg.For <ServiceLocatorProvider>().Use(serviceLocatorProvider));
     };
     context.EndRequest += (sender, e) => {
         HttpContextLifecycle.DisposeAndClearAll();
         StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
     };
 }
Ejemplo n.º 5
0
 protected void Application_EndRequest(object sender, EventArgs e)
 {
     try
     {
         foreach (var task in ProjectObjectFactory.Container.GetAllInstances <IRunAfterEachRequest>())
         {
             task.Execute();
         }
     }
     catch (Exception)
     {
         HttpContextLifecycle.DisposeAndClearAll();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 public static void ApplicationEndRequest()
 {
     try
     {
         foreach (var task in ContainerManager.Container.GetAllInstances <IRunAfterEachRequest>())
         {
             task.Execute();
         }
     }
     catch (Exception)
     {
         HttpContextLifecycle.DisposeAndClearAll();
     }
 }
Ejemplo n.º 7
0
        void WebApiApplication_EndRequest(object sender, EventArgs e)
        {
            using (IUnitOfWork unitOfWork = StructureMap.ObjectFactory.GetInstance <IUnitOfWork>())
            {
                try
                {
                    unitOfWork.Commit();
                }
                catch (Exception)
                {
                    unitOfWork.Rollback();
                }
            }

            HttpContextLifecycle.DisposeAndClearAll();
        }
Ejemplo n.º 8
0
 public void Init(HttpApplication context)
 {
     context.BeginRequest += (sender, e) => LocatorStartup.Locator.CreateNestedContainer();
     context.EndRequest   += (sender, e) =>
     {
         try
         {
             HttpContextLifecycle.DisposeAndClearAll();
             LocatorStartup.Locator.DisposeNestedContainer();
         }
         catch (InvalidOperationException)
         {
             // Catch HttpContextLifecycle.DisposeAndClearAll(); issues
         }
     };
 }
Ejemplo n.º 9
0
 public void Init(HttpApplication context)
 {
     try
     {
         context.BeginRequest += (sender, e) => StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
         context.EndRequest   += (sender, e) =>
         {
             HttpContextLifecycle.DisposeAndClearAll();
             StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
         };
     }
     catch (Exception e)
     {
         Commons.Logger.GenerateError(e, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
     }
 }
 public void Init(HttpApplication context)
 {
     context.BeginRequest += (sender, e) =>
     {
         StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
         foreach (var task in StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer.GetAllInstances <IRunOnEachRequest>())
         {
             task.Execute();
         }
     };
     context.Error += (sender, e) =>
     {
         if (StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer != null)
         {
             foreach (var task in StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer
                      .GetAllInstances <IRunOnError>())
             {
                 task.Execute();
             }
         }
         else
         {
             StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
             foreach (var task in StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer
                      .GetAllInstances <IRunOnError>())
             {
                 task.Execute();
             }
             HttpContextLifecycle.DisposeAndClearAll();
             StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
         }
     };
     context.EndRequest += (sender, e) => {
         try
         {
             foreach (var task in StructuremapMvc.StructureMapDependencyScope.CurrentNestedContainer.GetAllInstances <IRunAfterEachRequest>())
             {
                 task.Execute();
             }
         }
         finally
         {
             HttpContextLifecycle.DisposeAndClearAll();
             StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
         }
     };
 }
Ejemplo n.º 11
0
        public void Application_EndRequest(Object sender, EventArgs e)
        {
            try
            {
                foreach (var task in IoC.StructureMapResolver.CurrentNestedContainer.GetAllInstances <IRunAfterEachRequest>())
                {
                    task.Execute();
                }
            }
            finally
            {
                HttpContextLifecycle.DisposeAndClearAll();
                IoC.StructureMapResolver.DisposeNestedContainer();
            }

            DataContext.DisposeCurrent();
        }
Ejemplo n.º 12
0
        public void Init(HttpApplication context)
        {
            context.BeginRequest += (sender, e) =>
            {
                StructuremapMvc.StructureMapDependencyScope.CreateNestedContainer();
                var transactionManager = StructuremapMvc.StructureMapDependencyScope.GetInstance <ITransactionManager>();
                //lazy mode, no need start tx;
                LogMessage("BeginRequest: " + transactionManager.GetHashCode());
            };
            context.EndRequest += (sender, e) =>
            {
                HttpContextLifecycle.DisposeAndClearAll();
                StructuremapMvc.StructureMapDependencyScope.DisposeNestedContainer();
                LogMessage("EndRequest");
            };

            context.Error += (sender, args) =>
            {
                //not work for webapi, use WebApiTransactionFilter
                var transactionManager = StructuremapMvc.StructureMapDependencyScope.GetInstance <ITransactionManager>();
                transactionManager.Cancel();
                LogMessage("Request Ex: transactionManager.Cancel()");
            };
        }
Ejemplo n.º 13
0
 private void Application_EndRequest(object sender, EventArgs e)
 {
     //ObjectFactory.ReleaseAndDisposeAllHttpScopedObjects();
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 14
0
 protected void Application_EndRequest(object sender, EventArgs e)
 {
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 15
0
 public void cleanup()
 {
     // SAMPLE: clean-up-http-context
     HttpContextLifecycle.DisposeAndClearAll();
     // ENDSAMPLE
 }
Ejemplo n.º 16
0
 public static void ReleasePerRequesInstances()
 {
     HttpContext.Current.Items.Clear();
     HttpContextLifecycle.DisposeAndClearAll();
 }
 public void OnResultExecuted(ResultExecutedContext filterContext)
 {
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 18
0
 /// <summary>
 ///
 /// </summary>
 protected void Application_EndRequest()
 {
     //this code dispose all resource like DbContext etc.
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 19
0
 private static void ShutDown()
 {
     NHibernateContext.EndTransactions();
     HttpContextLifecycle.DisposeAndClearAll();
     StructuremapConfig.StructureMapResolver.DisposeNestedContainer();
 }
Ejemplo n.º 20
0
 public void HandleIncomingRequestProcessed()
 {
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Handles the EndRequest event of the Application control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void Application_EndRequest(object sender, EventArgs e)
 {
     // Make sure to dispose RavenDB session if created on this web request
     HttpContextLifecycle.DisposeAndClearAll();
 }
 private void Application_EndRequest(object sender, EventArgs e)
 {
     //تخریب تمام اشیا ساخته شده توسط استراکچرمپ و برگشت منابع در صورتی که طول عمر شی براساس درخواست باشد
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Remove and dispose all objects scoped by HttpContext.  Call this method at the *end* of an Http request to clean up resources
 /// </summary>
 public static void ReleaseAndDisposeAllHttpScopedObjects()
 {
     HttpContextLifecycle.DisposeAndClearAll();
 }
Ejemplo n.º 24
0
 public static void HttpContextDisposeAndClearAll()
 {
     HttpContextLifecycle.DisposeAndClearAll();
 }
 /// <summary>
 /// Application request end hook.
 /// </summary>
 protected void Application_EndRequest()
 {
     HttpContextLifecycle.DisposeAndClearAll();
 }