mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 03:14:10 +08:00
Merge pull request #6507 from jtkech/patch-15
ContextState: Attempt to fix specflows on teamcity
This commit is contained in:
@@ -30,8 +30,8 @@
|
|||||||
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||||
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||||
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||||
<add assembly="Orchard.Framework,Culture=neutral, PublicKeyToken=null" />
|
<add assembly="Orchard.Framework" />
|
||||||
<add assembly="Orchard.Core,Culture=neutral, PublicKeyToken=null" />
|
<add assembly="Orchard.Core" />
|
||||||
</assemblies>
|
</assemblies>
|
||||||
</compilation>
|
</compilation>
|
||||||
</system.web>
|
</system.web>
|
||||||
|
@@ -30,8 +30,8 @@
|
|||||||
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||||
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||||
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||||
<add assembly="Orchard.Framework,Culture=neutral, PublicKeyToken=null" />
|
<add assembly="Orchard.Framework" />
|
||||||
<add assembly="Orchard.Core,Culture=neutral, PublicKeyToken=null" />
|
<add assembly="Orchard.Core" />
|
||||||
</assemblies>
|
</assemblies>
|
||||||
</compilation>
|
</compilation>
|
||||||
</system.web>
|
</system.web>
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Remoting;
|
||||||
using System.Runtime.Remoting.Messaging;
|
using System.Runtime.Remoting.Messaging;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Orchard.Mvc.Extensions;
|
using Orchard.Mvc.Extensions;
|
||||||
@@ -23,11 +24,15 @@ namespace Orchard.Environment.State {
|
|||||||
|
|
||||||
public T GetState() {
|
public T GetState() {
|
||||||
if (HttpContext.Current.IsBackgroundHttpContext()) {
|
if (HttpContext.Current.IsBackgroundHttpContext()) {
|
||||||
|
// Because CallContext Logical Data can be shared across application domains,
|
||||||
|
// here we also check if it's a real local instance, not a tranparent proxy.
|
||||||
var handle = CallContext.LogicalGetData(_name) as ObjectHandle;
|
var handle = CallContext.LogicalGetData(_name) as ObjectHandle;
|
||||||
var data = handle != null ? handle.Unwrap() : null;
|
var data = handle != null && !RemotingServices.IsTransparentProxy(handle) ? handle.Unwrap() : null;
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
if (_defaultValue != null) {
|
if (_defaultValue != null) {
|
||||||
|
// Because CallContext Logical Data can be shared across application domains,
|
||||||
|
// data are wrapped in an ObjectHandle that inherits from MarshalByRefObject.
|
||||||
CallContext.LogicalSetData(_name, new ObjectHandle(data = _defaultValue()));
|
CallContext.LogicalSetData(_name, new ObjectHandle(data = _defaultValue()));
|
||||||
return data as T;
|
return data as T;
|
||||||
}
|
}
|
||||||
@@ -51,12 +56,5 @@ namespace Orchard.Environment.State {
|
|||||||
HttpContext.Current.Items[_name] = state;
|
HttpContext.Current.Items[_name] = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class ObjectHandle : System.Runtime.Remoting.ObjectHandle {
|
|
||||||
public ObjectHandle(object o) : base(o) { }
|
|
||||||
public override object InitializeLifetimeService() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user