Class OptionalDisposable
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
Creates instances of OptionalDisposable<T> type.
public static class OptionalDisposable
- Inheritance
-
OptionalDisposable
- Inherited Members
Methods
Create<T>(T)
Creates a new OptionalDisposable<T> instance.
[Pure]
public static OptionalDisposable<T> Create<T>(T value) where T : IDisposable
Parameters
valueTDisposable underlying object.
Returns
- OptionalDisposable<T>
New OptionalDisposable<T> instance.
Type Parameters
TObject type.
GetUnderlyingType(Type?)
Attempts to extract the underlying type from the provided OptionalDisposable<T>type.
[Pure]
public static Type? GetUnderlyingType(Type? type)
Parameters
typeTypeType to extract the underlying type from.
Returns
- Type
Underlying OptionalDisposable<T> type or null when the provided
typeis not related to the OptionalDisposable<T> type.
TryCreate<T>(T?)
Attempts to create a new OptionalDisposable<T> instance.
[Pure]
public static OptionalDisposable<T> TryCreate<T>(T? value) where T : struct, IDisposable
Parameters
valueT?Disposable underlying object.
Returns
- OptionalDisposable<T>
New OptionalDisposable<T> instance or Empty when
valueis null.
Type Parameters
TObject type.
TryCreate<T>(T?)
Attempts to create a new OptionalDisposable<T> instance.
[Pure]
public static OptionalDisposable<T> TryCreate<T>(T? value) where T : IDisposable
Parameters
valueTDisposable underlying object.
Returns
- OptionalDisposable<T>
New OptionalDisposable<T> instance or Empty when
valueis null.
Type Parameters
TObject type.