mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Update WorkContextAccessor.cs
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Remoting;
|
||||||
using System.Runtime.Remoting.Messaging;
|
using System.Runtime.Remoting.Messaging;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
@@ -27,7 +28,8 @@ namespace Orchard.Environment {
|
|||||||
if (!httpContext.IsBackgroundContext())
|
if (!httpContext.IsBackgroundContext())
|
||||||
return httpContext.Items[_workContextKey] as WorkContext;
|
return httpContext.Items[_workContextKey] as WorkContext;
|
||||||
|
|
||||||
return CallContext.LogicalGetData("WorkContext") as WorkContext;
|
var context = CallContext.LogicalGetData("WorkContext") as ObjectHandle;
|
||||||
|
return context != null ? context.Unwrap() as WorkContext : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkContext GetContext() {
|
public WorkContext GetContext() {
|
||||||
@@ -35,7 +37,8 @@ namespace Orchard.Environment {
|
|||||||
if (!httpContext.IsBackgroundContext())
|
if (!httpContext.IsBackgroundContext())
|
||||||
return GetContext(httpContext);
|
return GetContext(httpContext);
|
||||||
|
|
||||||
return CallContext.LogicalGetData("WorkContext") as WorkContext;
|
var context = CallContext.LogicalGetData("WorkContext") as ObjectHandle;
|
||||||
|
return context != null ? context.Unwrap() as WorkContext : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext) {
|
public IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext) {
|
||||||
@@ -104,11 +107,11 @@ namespace Orchard.Environment {
|
|||||||
|
|
||||||
public CallContextScopeImplementation(IEnumerable<IWorkContextEvents> events, ILifetimeScope lifetimeScope) {
|
public CallContextScopeImplementation(IEnumerable<IWorkContextEvents> events, ILifetimeScope lifetimeScope) {
|
||||||
_workContext = lifetimeScope.Resolve<WorkContext>();
|
_workContext = lifetimeScope.Resolve<WorkContext>();
|
||||||
CallContext.LogicalSetData("WorkContext", _workContext);
|
CallContext.LogicalSetData("WorkContext", new ObjectHandle(_workContext));
|
||||||
|
|
||||||
CallContext.LogicalSetData("HttpContext", null);
|
CallContext.LogicalSetData("HttpContext", null);
|
||||||
var httpContext = lifetimeScope.Resolve<HttpContextBase>();
|
var httpContext = lifetimeScope.Resolve<HttpContextBase>();
|
||||||
CallContext.LogicalSetData("HttpContext", httpContext);
|
CallContext.LogicalSetData("HttpContext", new ObjectHandle(httpContext));
|
||||||
|
|
||||||
_disposer = () => {
|
_disposer = () => {
|
||||||
events.Invoke(e => e.Finished(), NullLogger.Instance);
|
events.Invoke(e => e.Finished(), NullLogger.Instance);
|
||||||
|
Reference in New Issue
Block a user