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
IsDisposed
Specifies whether or not this scope has been disposed.
bool IsDisposed { get; }
Property Value
IsRoot
Specifies whether or not this scope is a root scope.
bool IsRoot { get; }
Property Value
Level
Depth of this scope. Equal to 0 when this scope is a root scope.
int Level { get; }
Property Value
Locator
Non-keyed dependency locator associated with this scope.
IDependencyLocator Locator { get; }
Property Value
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
OriginalThreadId
Specifies the CurrentManagedThreadId of the Thread that created this scope.
int OriginalThreadId { get; }
Property Value
ParentScope
Parent scope of this scope or null when this scope is a root scope.
IDependencyScope? ParentScope { get; }
Property Value
Methods
BeginScope(string?)
Creates a new IChildDependencyScope from this scope.
[Pure]
IChildDependencyScope BeginScope(string? name = null)
Parameters
name
stringOptional 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
TKeyLocator's key.
Returns
- IDependencyLocator<TKey>
IDependencyLocator<TKey> instance associated with this scope and the provided
key
.
Type Parameters
TKey
Locator's key type.