Class LazyDisposable<T>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
Represents a generic lazy container for an optional disposable object.
public sealed class LazyDisposable<T> : IDisposable where T : IDisposable
Type Parameters
T
Object type.
- Inheritance
-
LazyDisposable<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
LazyDisposable()
Creates a new LazyDisposable<T> instance without an Inner object.
public LazyDisposable()
Properties
CanAssign
Specifies whether or not an underlying Inner object can be assigned to this instance.
public bool CanAssign { get; }
Property Value
Inner
Optional underlying disposable object.
public T? Inner { get; }
Property Value
- T
IsDisposed
Specifies whether or not this instance has already been disposed.
public bool IsDisposed { get; }
Property Value
Methods
Assign(T)
Assigns an object to the underlying Inner object.
public void Assign(T inner)
Parameters
inner
TObject to assign.
Remarks
Will dispose the Inner object immediately upon assignment if this instance has been already disposed.
Exceptions
- InvalidOperationException
When Inner object has already been assigned.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
Disposes the underlying Inner object if it exists.