Class XDisposable
- Namespace
- Prefrontal.Common.Extensions
- Assembly
- Prefrontal.Core.dll
Provides extension methods for IDisposable.
public static class XDisposable
- Inheritance
-
XDisposable
- Inherited Members
Methods
UseForAsync<T>(T, Func<T, Task>)
Use the disposable object for a single operation. This method ensures that the disposable object is disposed of after the operation is completed.
public static Task UseForAsync<T>(this T asyncDisposable, Func<T, Task> operation) where T : IAsyncDisposable
Parameters
asyncDisposable
TAn object that implements IAsyncDisposable.
operation
Func<T, Task>The operation to perform while using the disposable object.
Returns
Type Parameters
T
Type of the disposable object.
UseForAsync<T, TOut>(T, Func<T, Task<TOut>>)
Use the disposable object for a single operation. This method ensures that the disposable object is disposed of after the operation is completed.
public static Task<TOut> UseForAsync<T, TOut>(this T asyncDisposable, Func<T, Task<TOut>> operation) where T : IAsyncDisposable
Parameters
asyncDisposable
TAn object that implements IAsyncDisposable.
operation
Func<T, Task<TOut>>The operation to perform while using the disposable object.
Returns
- Task<TOut>
Type Parameters
T
Type of the disposable object.
TOut
Type of the operation's result.
UseFor<T>(T, Action<T>)
Use the disposable object for a single operation. This method ensures that the disposable object is disposed of after the operation is completed.
public static void UseFor<T>(this T disposable, Action<T> operation) where T : IDisposable
Parameters
disposable
TAn object that implements IDisposable.
operation
Action<T>The operation to perform while using the disposable object.
Type Parameters
T
Type of the disposable object.
UseFor<T, TOut>(T, Func<T, TOut>)
Use the disposable object for a single operation. This method ensures that the disposable object is disposed of after the operation is completed.
public static TOut UseFor<T, TOut>(this T disposable, Func<T, TOut> operation) where T : IDisposable
Parameters
disposable
TAn object that implements IDisposable.
operation
Func<T, TOut>The operation to perform while using the disposable object.
Returns
- TOut
Type Parameters
T
Type of the disposable object.
TOut
Type of the operation's result.