Reverts how UmbracoContextReference works
This commit is contained in:
@@ -14,22 +14,24 @@ namespace Umbraco.Web
|
||||
/// </remarks>
|
||||
public class UmbracoContextReference : IDisposable //fixme - should we inherit from DisposableObjectSlim?
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoContextReference"/> class.
|
||||
/// </summary>
|
||||
internal UmbracoContextReference(bool isRoot, IUmbracoContext umbracoContext)
|
||||
internal UmbracoContextReference(IUmbracoContext umbracoContext, bool isRoot, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
IsRoot = isRoot;
|
||||
|
||||
UmbracoContext = umbracoContext;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="UmbracoContext"/>.
|
||||
/// </summary>
|
||||
public IUmbracoContext UmbracoContext { get; private set; }
|
||||
public IUmbracoContext UmbracoContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the reference is a root reference.
|
||||
@@ -49,7 +51,7 @@ namespace Umbraco.Web
|
||||
if (IsRoot)
|
||||
{
|
||||
UmbracoContext.Dispose();
|
||||
UmbracoContext = null;
|
||||
_umbracoContextAccessor.UmbracoContext = null;
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
@@ -77,13 +77,13 @@ namespace Umbraco.Web
|
||||
{
|
||||
var currentUmbracoContext = _umbracoContextAccessor.UmbracoContext;
|
||||
if (currentUmbracoContext != null)
|
||||
return new UmbracoContextReference(false, currentUmbracoContext);
|
||||
return new UmbracoContextReference(currentUmbracoContext, false, _umbracoContextAccessor);
|
||||
|
||||
|
||||
var umbracoContext = CreateUmbracoContext();
|
||||
_umbracoContextAccessor.UmbracoContext = umbracoContext;
|
||||
|
||||
return new UmbracoContextReference(true, umbracoContext);
|
||||
return new UmbracoContextReference(umbracoContext, true, _umbracoContextAccessor);
|
||||
}
|
||||
|
||||
// dummy TextWriter that does not write
|
||||
|
||||
Reference in New Issue
Block a user