Class ResultMatchExtensions
Extension methods for match operations on Result types.
public static class ResultMatchExtensions
- Inheritance
-
ResultMatchExtensions
- Inherited Members
Methods
Match(Result, Action, Action<ImmutableList<IError>>)
Executes one of two actions based on success or failure.
public static void Match(this Result result, Action onSuccess, Action<ImmutableList<IError>> onFailure)
Parameters
resultResultThe result to match.
onSuccessActionAction to execute on success.
onFailureAction<ImmutableList<IError>>Action to execute on failure with errors.
MatchAsync(Result, Func<Task>, Func<ImmutableList<IError>, Task>, CancellationToken)
Asynchronously executes one of two async actions based on success or failure.
public static Task MatchAsync(this Result result, Func<Task> onSuccess, Func<ImmutableList<IError>, Task> onFailure, CancellationToken cancellationToken = default)
Parameters
resultResultThe result to match.
onSuccessFunc<Task>Async action to execute on success.
onFailureFunc<ImmutableList<IError>, Task>Async action to execute on failure with errors.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- Task
A task representing the async operation.
MatchAsync<TOut>(Result, Func<Task<TOut>>, Func<ImmutableList<IError>, Task<TOut>>, CancellationToken)
Asynchronously matches result to one of two async functions based on success or failure.
public static Task<TOut> MatchAsync<TOut>(this Result result, Func<Task<TOut>> onSuccess, Func<ImmutableList<IError>, Task<TOut>> onFailure, CancellationToken cancellationToken = default)
Parameters
resultResultThe result to match.
onSuccessFunc<Task<TOut>>Async function to execute on success.
onFailureFunc<ImmutableList<IError>, Task<TOut>>Async function to execute on failure with errors.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- Task<TOut>
A task containing the result of the executed function.
Type Parameters
TOutThe return type.
MatchAsync<T>(Result<T>, Func<T, Task>, Func<ImmutableList<IError>, Task>, CancellationToken)
Asynchronously executes one of two async actions based on success or failure.
public static Task MatchAsync<T>(this Result<T> result, Func<T, Task> onSuccess, Func<ImmutableList<IError>, Task> onFailure, CancellationToken cancellationToken = default)
Parameters
resultResult<T>The result to match.
onSuccessFunc<T, Task>Async action to execute on success with value.
onFailureFunc<ImmutableList<IError>, Task>Async action to execute on failure with errors.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- Task
A task representing the async operation.
Type Parameters
TThe value type.
MatchAsync<T, TOut>(Result<T>, Func<T, Task<TOut>>, Func<ImmutableList<IError>, Task<TOut>>, CancellationToken)
Asynchronously matches result to one of two async functions based on success or failure.
public static Task<TOut> MatchAsync<T, TOut>(this Result<T> result, Func<T, Task<TOut>> onSuccess, Func<ImmutableList<IError>, Task<TOut>> onFailure, CancellationToken cancellationToken = default)
Parameters
resultResult<T>The result to match.
onSuccessFunc<T, Task<TOut>>Async function to execute on success with value.
onFailureFunc<ImmutableList<IError>, Task<TOut>>Async function to execute on failure with errors.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- Task<TOut>
A task containing the result of the executed function.
Type Parameters
TThe value type.
TOutThe return type.
Match<TOut>(Result, Func<TOut>, Func<ImmutableList<IError>, TOut>)
Matches result to one of two functions based on success or failure.
public static TOut Match<TOut>(this Result result, Func<TOut> onSuccess, Func<ImmutableList<IError>, TOut> onFailure)
Parameters
resultResultThe result to match.
onSuccessFunc<TOut>Function to execute on success.
onFailureFunc<ImmutableList<IError>, TOut>Function to execute on failure with errors.
Returns
- TOut
The result of the executed function.
Type Parameters
TOutThe return type.
Match<T>(Result<T>, Action<T>, Action<ImmutableList<IError>>)
Executes one of two actions based on success or failure.
public static void Match<T>(this Result<T> result, Action<T> onSuccess, Action<ImmutableList<IError>> onFailure)
Parameters
resultResult<T>The result to match.
onSuccessAction<T>Action to execute on success with value.
onFailureAction<ImmutableList<IError>>Action to execute on failure with errors.
Type Parameters
TThe value type.
Match<T, TOut>(Result<T>, Func<T, TOut>, Func<ImmutableList<IError>, TOut>)
Matches result to one of two functions based on success or failure.
public static TOut Match<T, TOut>(this Result<T> result, Func<T, TOut> onSuccess, Func<ImmutableList<IError>, TOut> onFailure)
Parameters
resultResult<T>The result to match.
onSuccessFunc<T, TOut>Function to execute on success with value.
onFailureFunc<ImmutableList<IError>, TOut>Function to execute on failure with errors.
Returns
- TOut
The result of the executed function.
Type Parameters
TThe value type.
TOutThe return type.