Class MatchExtensionsAsync
- Namespace
- FunctionalDdd
- Assembly
- FunctionalDdd.RailwayOrientedProgramming.dll
Asynchronous pattern matching helpers for Result.
public static class MatchExtensionsAsync
- Inheritance
-
MatchExtensionsAsync
- Inherited Members
Methods
MatchAsync<TIn, TOut>(Result<TIn>, Func<TIn, CancellationToken, Task<TOut>>, Func<Error, CancellationToken, Task<TOut>>, CancellationToken)
Executes either the success or failure async function based on the result state.
public static Task<TOut> MatchAsync<TIn, TOut>(this Result<TIn> result, Func<TIn, CancellationToken, Task<TOut>> onSuccess, Func<Error, CancellationToken, Task<TOut>> onFailure, CancellationToken cancellationToken = default)
Parameters
resultResult<TIn>The result to match on.
onSuccessFunc<TIn, CancellationToken, Task<TOut>>Async function to execute on success.
onFailureFunc<Error, CancellationToken, Task<TOut>>Async function to execute on failure.
cancellationTokenCancellationTokenCancellation token to observe.
Returns
- Task<TOut>
A task that represents the asynchronous operation. The task result contains the output from either the success or failure function.
Type Parameters
TInType of the result value.
TOutType of the output.
MatchAsync<TIn, TOut>(Result<TIn>, Func<TIn, Task<TOut>>, Func<Error, Task<TOut>>)
Executes either the success or failure async function based on the result state.
public static Task<TOut> MatchAsync<TIn, TOut>(this Result<TIn> result, Func<TIn, Task<TOut>> onSuccess, Func<Error, Task<TOut>> onFailure)
Parameters
resultResult<TIn>The result to match on.
onSuccessFunc<TIn, Task<TOut>>Async function to execute on success.
onFailureFunc<Error, Task<TOut>>Async function to execute on failure.
Returns
- Task<TOut>
A task that represents the asynchronous operation. The task result contains the output from either the success or failure function.
Type Parameters
TInType of the result value.
TOutType of the output.
MatchAsync<TIn, TOut>(Task<Result<TIn>>, Func<TIn, CancellationToken, Task<TOut>>, Func<Error, CancellationToken, Task<TOut>>, CancellationToken)
Executes either the success or failure async function based on the result state.
public static Task<TOut> MatchAsync<TIn, TOut>(this Task<Result<TIn>> resultTask, Func<TIn, CancellationToken, Task<TOut>> onSuccess, Func<Error, CancellationToken, Task<TOut>> onFailure, CancellationToken cancellationToken = default)
Parameters
resultTaskTask<Result<TIn>>The task representing the result to match on.
onSuccessFunc<TIn, CancellationToken, Task<TOut>>Async function to execute on success.
onFailureFunc<Error, CancellationToken, Task<TOut>>Async function to execute on failure.
cancellationTokenCancellationTokenCancellation token to observe.
Returns
- Task<TOut>
A task that represents the asynchronous operation. The task result contains the output from either the success or failure function.
Type Parameters
TInType of the result value.
TOutType of the output.
MatchAsync<TIn, TOut>(Task<Result<TIn>>, Func<TIn, Task<TOut>>, Func<Error, Task<TOut>>)
Executes either the success or failure async function based on the result state.
public static Task<TOut> MatchAsync<TIn, TOut>(this Task<Result<TIn>> resultTask, Func<TIn, Task<TOut>> onSuccess, Func<Error, Task<TOut>> onFailure)
Parameters
resultTaskTask<Result<TIn>>The task representing the result to match on.
onSuccessFunc<TIn, Task<TOut>>Async function to execute on success.
onFailureFunc<Error, Task<TOut>>Async function to execute on failure.
Returns
- Task<TOut>
A task that represents the asynchronous operation. The task result contains the output from either the success or failure function.
Type Parameters
TInType of the result value.
TOutType of the output.
MatchAsync<TIn, TOut>(Task<Result<TIn>>, Func<TIn, TOut>, Func<Error, TOut>)
Executes either the success or failure function based on the result state.
public static Task<TOut> MatchAsync<TIn, TOut>(this Task<Result<TIn>> resultTask, Func<TIn, TOut> onSuccess, Func<Error, TOut> onFailure)
Parameters
resultTaskTask<Result<TIn>>The task representing the result to match on.
onSuccessFunc<TIn, TOut>Function to execute on success.
onFailureFunc<Error, TOut>Function to execute on failure.
Returns
- Task<TOut>
The output from either the success or failure function.
Type Parameters
TInType of the result value.
TOutType of the output.
SwitchAsync<TIn>(Task<Result<TIn>>, Func<TIn, CancellationToken, Task>, Func<Error, CancellationToken, Task>, CancellationToken)
Executes either the success or failure async action based on the result state.
public static Task SwitchAsync<TIn>(this Task<Result<TIn>> resultTask, Func<TIn, CancellationToken, Task> onSuccess, Func<Error, CancellationToken, Task> onFailure, CancellationToken cancellationToken = default)
Parameters
resultTaskTask<Result<TIn>>The task representing the result to switch on.
onSuccessFunc<TIn, CancellationToken, Task>Async action to execute on success.
onFailureFunc<Error, CancellationToken, Task>Async action to execute on failure.
cancellationTokenCancellationTokenCancellation token to observe.
Returns
- Task
A task that represents the asynchronous operation.
Type Parameters
TInType of the result value.
SwitchAsync<TIn>(Task<Result<TIn>>, Func<TIn, Task>, Func<Error, Task>)
Executes either the success or failure async action based on the result state.
public static Task SwitchAsync<TIn>(this Task<Result<TIn>> resultTask, Func<TIn, Task> onSuccess, Func<Error, Task> onFailure)
Parameters
resultTaskTask<Result<TIn>>The task representing the result to switch on.
onSuccessFunc<TIn, Task>Async action to execute on success.
onFailureFunc<Error, Task>Async action to execute on failure.
Returns
- Task
A task that represents the asynchronous operation.
Type Parameters
TInType of the result value.