Skip to content

Commit

Permalink
Move the set of the curr3ent.Value to the ctor from the ExtensionCont…
Browse files Browse the repository at this point in the history
…ainerRoot

castleproject#563
  • Loading branch information
generik0 committed Dec 10, 2020
1 parent 36ac910 commit 3a3a63e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ private ExtensionContainerRootScope() : base(null)

public static ExtensionContainerRootScope BeginRootScope()
{
var scope = new ExtensionContainerRootScope();
current.Value = scope;
return scope;
return new ExtensionContainerRootScope();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace Castle.Windsor.Extensions.DependencyInjection.Scope

internal class ExtensionContainerScope : ILifetimeScope, IDisposable
{

/// <summary>Current scope for the thread. Initial scope will be set when calling BeginRootScope from a ExtensionContainerRootScope instance.</summary>
/// <exception cref="InvalidOperationException">Thrown when there is no scope available.</exception>
internal static ExtensionContainerScope Current
{
get => current.Value ?? throw new InvalidOperationException("No scope available");
Expand All @@ -38,15 +41,14 @@ protected ExtensionContainerScope(ExtensionContainerScope parent)
scopeCache = new ScopeCache();
RootScope = parent?.RootScope ?? this as ExtensionContainerRootScope;
this.parent = parent;
current.Value = this;
}

internal ExtensionContainerRootScope RootScope { get; }

internal static ExtensionContainerScope BeginScope()
{
var scope = new ExtensionContainerScope(Current);
current.Value = scope;
return scope;
return new ExtensionContainerScope(Current);
}

public void Dispose()
Expand Down

0 comments on commit 3a3a63e

Please sign in to comment.