Class Scope<T>
Provides a scope for managing a resource with automatic disposal.
public sealed class Scope<T> : Disposable, IDisposable
Type Parameters
T
The type of the resource to be managed.
- Inheritance
-
Scope<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
Scope()
Initializes a new instance of the Scope<T> class with a new instance of T.
public Scope()
Scope(T)
Initializes a new instance of the Scope<T> class with the specified value.
public Scope(T value)
Parameters
value
TThe instance of T to be managed.
Scope(T, bool)
Initializes a new instance of the Scope<T> class with the specified value and ownership.
public Scope(T value, bool ownInstance)
Parameters
value
TThe instance of T to be managed.
ownInstance
boolIndicates whether the scope owns the instance and is responsible for disposing it.
Properties
All
Gets all scopes in the current hierarchy as a collection.
public static ICollection<Scope<T>> All { get; }
Property Value
- ICollection<Scope<T>>
Current
Gets the current scope.
public static Scope<T> Current { get; }
Property Value
- Scope<T>
IsDefined
Gets a value indicating whether a current scope is defined.
public static bool IsDefined { get; }
Property Value
OwnInstance
Gets a value indicating whether the scope owns the managed instance.
public bool OwnInstance { get; }
Property Value
Parent
Gets the parent scope of the current scope.
public Scope<T> Parent { get; }
Property Value
- Scope<T>
Value
Gets the value contained in the scope.
public T Value { get; }
Property Value
- T
Methods
DisposeManaged()
Disposes the managed resources used by the Scope<T> class.
protected override void DisposeManaged()
Remarks
Throws an InvalidOperationException if disposed out of order.