Table of Contents

Interface IDependencyScope

Namespace
LfrlAnvil.Dependencies
Assembly
LfrlAnvil.Dependencies.dll

Represents a dependency scope.

public interface IDependencyScope

Properties

Container

IDependencyContainer associated with this scope.

IDependencyContainer Container { get; }

Property Value

IDependencyContainer

IsDisposed

Specifies whether or not this scope has been disposed.

bool IsDisposed { get; }

Property Value

bool

IsRoot

Specifies whether or not this scope is a root scope.

bool IsRoot { get; }

Property Value

bool

Level

Depth of this scope. Equal to 0 when this scope is a root scope.

int Level { get; }

Property Value

int

Locator

Non-keyed dependency locator associated with this scope.

IDependencyLocator Locator { get; }

Property Value

IDependencyLocator

Name

Optional name of this scope. If it is not null then this scope can be retrieved by invoking the GetScope(string) method.

string? Name { get; }

Property Value

string

OriginalThreadId

Specifies the CurrentManagedThreadId of the Thread that created this scope.

int OriginalThreadId { get; }

Property Value

int

ParentScope

Parent scope of this scope or null when this scope is a root scope.

IDependencyScope? ParentScope { get; }

Property Value

IDependencyScope

Methods

BeginScope(string?)

Creates a new IChildDependencyScope from this scope.

[Pure]
IChildDependencyScope BeginScope(string? name = null)

Parameters

name string

Optional child scope's name.

Returns

IChildDependencyScope

New IChildDependencyScope instance.

Exceptions

NamedDependencyScopeCreationException

When the scope is named and that name already exists.

GetChildren()

Retrieves all child scopes created by this scope.

[Pure]
IDependencyScope[] GetChildren()

Returns

IDependencyScope[]

Collection of child scopes created by this scope.

GetKeyedLocator<TKey>(TKey)

Gets the keyed locator associated with this scope by its key.

[Pure]
IDependencyLocator<TKey> GetKeyedLocator<TKey>(TKey key) where TKey : notnull

Parameters

key TKey

Locator's key.

Returns

IDependencyLocator<TKey>

IDependencyLocator<TKey> instance associated with this scope and the provided key.

Type Parameters

TKey

Locator's key type.