Skip to content

Commit

Permalink
Change BeginScope and BeginRootScope to set current
Browse files Browse the repository at this point in the history
  • Loading branch information
generik0 committed Dec 10, 2020
1 parent 414887d commit e039c17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ namespace Castle.Windsor.Extensions.DependencyInjection.Scope
{
internal class ExtensionContainerRootScope : ExtensionContainerScopeBase
{
public ExtensionContainerRootScope()
{
SetCurrentToThis();
}


public static ExtensionContainerRootScope BeginRootScope()
{
return new ExtensionContainerRootScope();
var scope = new ExtensionContainerRootScope();
Current = scope;
return scope;
}

internal override ExtensionContainerScopeBase RootScope => this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@

namespace Castle.Windsor.Extensions.DependencyInjection.Scope
{
using System.Runtime.CompilerServices;

internal class ExtensionContainerScope : ExtensionContainerScopeBase
{
private readonly ExtensionContainerScopeBase parent;

protected ExtensionContainerScope()
{
parent = Current;
RootScope = parent.RootScope;
SetCurrentToThis();
}

internal override ExtensionContainerScopeBase RootScope { get; set; }


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

public override void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ internal static ExtensionContainerScopeBase Current

internal virtual ExtensionContainerScopeBase RootScope { get; set; }

internal void SetCurrentToThis()
{
Current = this;
}

public virtual void Dispose()
{
if (scopeCache is IDisposable disposableCache)
Expand Down

0 comments on commit e039c17

Please sign in to comment.