Introduce IUmbracoContextFactory

This commit is contained in:
Stephan
2019-02-14 12:11:06 +01:00
parent e5142e4915
commit 186e8fc58b
20 changed files with 285 additions and 249 deletions

View File

@@ -44,7 +44,10 @@ namespace Umbraco.Web.Composing
CoreCurrent.Resetted += (sender, args) =>
{
if (_umbracoContextAccessor != null)
ClearUmbracoContext();
{
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
umbracoContext?.Dispose();
}
_umbracoContextAccessor = null;
};
}
@@ -75,18 +78,6 @@ namespace Umbraco.Web.Composing
set => _umbracoContextAccessor = value; // for tests
}
// clears the "current" umbraco context
// at the moment the "current" umbraco context can end up being disposed and should get cleared
// in the accessor - this should be done differently but for the time being we have to support it
public static void ClearUmbracoContext()
{
lock (Locker)
{
UmbracoContextAccessor.UmbracoContext?.Dispose(); // dispose the one that is being cleared, if any
UmbracoContextAccessor.UmbracoContext = null;
}
}
#endregion
#region Web Getters