diff --git a/src/Umbraco.Core/AmbientContext.cs b/src/Umbraco.Core/AmbientContext.cs deleted file mode 100644 index cce488e036..0000000000 --- a/src/Umbraco.Core/AmbientContext.cs +++ /dev/null @@ -1,102 +0,0 @@ -//#define CALLCONTEXT -#define LOGICALCONTEXT - -using System.Collections.Generic; -using System.Runtime.Remoting.Messaging; -using System.Web; - -namespace Umbraco.Core -{ - // fixme - not used at the moment, instead we have the IScopeContextAdapter thing - // - // the scope context adapter needs to be created and passed around... whereas... this "just exists" - // and it's possible to do AmbientContext.Get(key) just anywhere and it will use the "ambient" context, - // which is based upon HttpContext in the context of a web request, or CallContext otherwise. - // - // read: - // https://github.com/seesharper/LightInject/issues/170 - // http://stackoverflow.com/questions/22924048/is-it-possible-to-detect-if-you-are-on-the-synchronous-side-of-an-async-method - // http://stackoverflow.com/questions/29917671/lightinject-with-web-api-how-can-i-get-the-httprequestmessage - // http://stackoverflow.com/questions/18459916/httpcontext-current-items-after-an-async-operation - // http://stackoverflow.com/questions/12029091/httpcontext-is-null-after-await-task-factory-fromasyncbeginxxx-endxxx - // - // also note - // CallContext stuff will flow downwards in async but not upwards ie an async call will receive the values - // but any changes it makes will *not* modify the caller's CallContext, so we should be careful when using - // this for caches and stuff - - internal static class AmbientContext - { - /// - /// Gets or sets the values container. - /// - /// For unit tests EXCLUSIVELY. - internal static IDictionary Values { get; set; } - - public static object Get(string key) - { - if (Values != null) - { - object value; - return Values.TryGetValue(key, out value) ? value : null; - } - - return HttpContext.Current == null -#if CALLCONTEXT - ? CallContext.GetData(key) -#elif LOGICALCONTEXT - ? CallContext.LogicalGetData(key) -#endif - : HttpContext.Current.Items[key]; - } - - public static void Set(string key, object value) - { - if (Values != null) - { - if (value != null) - Values[key] = value; - else - Values.Remove(key); - return; - } - - if (HttpContext.Current == null) - { - if (value != null) -#if CALLCONTEXT - CallContext.SetData(key, value); -#elif LOGICALCONTEXT - CallContext.LogicalSetData(key, value); -#endif - else -#if CALLCONTEXT || LOGICALCONTEXT - CallContext.FreeNamedDataSlot(key); // clears both -#endif - } - else - { - if (value != null) - HttpContext.Current.Items[key] = value; - else - HttpContext.Current.Items.Remove(key); - } - } - - public static void Clear(string key) - { - if (Values != null) - { - Values.Remove(key); - return; - } - - if (HttpContext.Current == null) -#if CALLCONTEXT || LOGICALCONTEXT - CallContext.FreeNamedDataSlot(key); // clears both -#endif - else - HttpContext.Current.Items.Remove(key); - } - } -} diff --git a/src/Umbraco.Core/DefaultScopeContextAdapter.cs b/src/Umbraco.Core/DefaultScopeContextAdapter.cs index 94c358b976..e584f1a6c0 100644 --- a/src/Umbraco.Core/DefaultScopeContextAdapter.cs +++ b/src/Umbraco.Core/DefaultScopeContextAdapter.cs @@ -5,6 +5,20 @@ namespace Umbraco.Core { internal class DefaultScopeContextAdapter : IScopeContextAdapter { + + // some reading: + // fixme: do we need to keep these links? + // https://github.com/seesharper/LightInject/issues/170 + // http://stackoverflow.com/questions/22924048/is-it-possible-to-detect-if-you-are-on-the-synchronous-side-of-an-async-method + // http://stackoverflow.com/questions/29917671/lightinject-with-web-api-how-can-i-get-the-httprequestmessage + // http://stackoverflow.com/questions/18459916/httpcontext-current-items-after-an-async-operation + // http://stackoverflow.com/questions/12029091/httpcontext-is-null-after-await-task-factory-fromasyncbeginxxx-endxxx + // + // also note + // CallContext stuff will flow downwards in async but not upwards ie an async call will receive the values + // but any changes it makes will *not* modify the caller's CallContext, so we should be careful when using + // this for caches and stuff + // fixme - should we use the LogicalCallContext here? public object Get(string key) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 834485deb1..90afb9e0e0 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -143,7 +143,6 @@ -