Table of Contents

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

value T

Disposable underlying object.

Returns

OptionalDisposable<T>

New OptionalDisposable<T> instance.

Type Parameters

T

Object type.

GetUnderlyingType(Type?)

Attempts to extract the underlying type from the provided OptionalDisposable<T>type.

[Pure]
public static Type? GetUnderlyingType(Type? type)

Parameters

type Type

Type to extract the underlying type from.

Returns

Type

Underlying OptionalDisposable<T> type or null when the provided type is 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

value T?

Disposable underlying object.

Returns

OptionalDisposable<T>

New OptionalDisposable<T> instance or Empty when value is null.

Type Parameters

T

Object 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

value T

Disposable underlying object.

Returns

OptionalDisposable<T>

New OptionalDisposable<T> instance or Empty when value is null.

Type Parameters

T

Object type.