Class WhenExtensionsAsync
- Namespace
- FunctionalDdd
- Assembly
- FunctionalDdd.RailwayOrientedProgramming.dll
Asynchronous conditional execution operations for Result.
public static class WhenExtensionsAsync
- Inheritance
-
WhenExtensionsAsync
- Inherited Members
Remarks
Users should capture CancellationToken in their lambda closures when cancellation support is needed.
Methods
UnlessAsync<T>(Result<T>, bool, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the condition is false.
public static Task<Result<T>> UnlessAsync<T>(this Result<T> result, bool condition, Func<T, Task<Result<T>>> operation)
Parameters
resultResult<T>The result to test.
conditionboolBoolean condition.
operationFunc<T, Task<Result<T>>>Async operation to execute if condition is false.
Returns
- Task<Result<T>>
Result from the operation if condition is false and result is success; otherwise the original result.
Type Parameters
TType of the result value.
UnlessAsync<T>(Result<T>, Func<T, bool>, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the predicate returns false.
public static Task<Result<T>> UnlessAsync<T>(this Result<T> result, Func<T, bool> predicate, Func<T, Task<Result<T>>> operation)
Parameters
resultResult<T>The result to test.
predicateFunc<T, bool>Predicate function to test the value.
operationFunc<T, Task<Result<T>>>Async operation to execute if predicate is false.
Returns
- Task<Result<T>>
Result from the operation if predicate is false and result is success; otherwise the original result.
Type Parameters
TType of the result value.
UnlessAsync<T>(Task<Result<T>>, bool, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the condition is false.
public static Task<Result<T>> UnlessAsync<T>(this Task<Result<T>> resultTask, bool condition, Func<T, Task<Result<T>>> operation)
Parameters
resultTaskTask<Result<T>>Task containing the result to test.
conditionboolBoolean condition.
operationFunc<T, Task<Result<T>>>Async operation to execute if condition is false.
Returns
- Task<Result<T>>
Result from the operation if condition is false and result is success; otherwise the original result.
Type Parameters
TType of the result value.
UnlessAsync<T>(Task<Result<T>>, Func<T, bool>, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the predicate returns false.
public static Task<Result<T>> UnlessAsync<T>(this Task<Result<T>> resultTask, Func<T, bool> predicate, Func<T, Task<Result<T>>> operation)
Parameters
resultTaskTask<Result<T>>Task containing the result to test.
predicateFunc<T, bool>Predicate function to test the value.
operationFunc<T, Task<Result<T>>>Async operation to execute if predicate is false.
Returns
- Task<Result<T>>
Result from the operation if predicate is false and result is success; otherwise the original result.
Type Parameters
TType of the result value.
UnlessAsync<T>(ValueTask<Result<T>>, Func<T, bool>, Func<T, ValueTask<Result<T>>>)
Conditionally executes an async operation if the predicate returns false.
public static ValueTask<Result<T>> UnlessAsync<T>(this ValueTask<Result<T>> resultTask, Func<T, bool> predicate, Func<T, ValueTask<Result<T>>> operation)
Parameters
resultTaskValueTask<Result<T>>ValueTask containing the result to test.
predicateFunc<T, bool>Predicate function to test the value.
operationFunc<T, ValueTask<Result<T>>>Async operation to execute if predicate is false.
Returns
- ValueTask<Result<T>>
Result from the operation if predicate is false and result is success; otherwise the original result.
Type Parameters
TType of the result value.
WhenAsync<T>(Result<T>, bool, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the condition is true.
public static Task<Result<T>> WhenAsync<T>(this Result<T> result, bool condition, Func<T, Task<Result<T>>> operation)
Parameters
resultResult<T>The result to test.
conditionboolBoolean condition.
operationFunc<T, Task<Result<T>>>Async operation to execute if condition is true.
Returns
- Task<Result<T>>
Result from the operation if condition is true and result is success; otherwise the original result.
Type Parameters
TType of the result value.
WhenAsync<T>(Result<T>, Func<T, bool>, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the predicate returns true.
public static Task<Result<T>> WhenAsync<T>(this Result<T> result, Func<T, bool> predicate, Func<T, Task<Result<T>>> operation)
Parameters
resultResult<T>The result to test.
predicateFunc<T, bool>Predicate function to test the value.
operationFunc<T, Task<Result<T>>>Async operation to execute if predicate is true.
Returns
- Task<Result<T>>
Result from the operation if predicate is true and result is success; otherwise the original result.
Type Parameters
TType of the result value.
WhenAsync<T>(Task<Result<T>>, bool, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the condition is true.
public static Task<Result<T>> WhenAsync<T>(this Task<Result<T>> resultTask, bool condition, Func<T, Task<Result<T>>> operation)
Parameters
resultTaskTask<Result<T>>Task containing the result to test.
conditionboolBoolean condition.
operationFunc<T, Task<Result<T>>>Async operation to execute if condition is true.
Returns
- Task<Result<T>>
Result from the operation if condition is true and result is success; otherwise the original result.
Type Parameters
TType of the result value.
WhenAsync<T>(Task<Result<T>>, Func<T, bool>, Func<T, Task<Result<T>>>)
Conditionally executes an async operation if the predicate returns true.
public static Task<Result<T>> WhenAsync<T>(this Task<Result<T>> resultTask, Func<T, bool> predicate, Func<T, Task<Result<T>>> operation)
Parameters
resultTaskTask<Result<T>>Task containing the result to test.
predicateFunc<T, bool>Predicate function to test the value.
operationFunc<T, Task<Result<T>>>Async operation to execute if predicate is true.
Returns
- Task<Result<T>>
Result from the operation if predicate is true and result is success; otherwise the original result.
Type Parameters
TType of the result value.
WhenAsync<T>(ValueTask<Result<T>>, Func<T, bool>, Func<T, ValueTask<Result<T>>>)
Conditionally executes an async operation if the predicate returns true.
public static ValueTask<Result<T>> WhenAsync<T>(this ValueTask<Result<T>> resultTask, Func<T, bool> predicate, Func<T, ValueTask<Result<T>>> operation)
Parameters
resultTaskValueTask<Result<T>>ValueTask containing the result to test.
predicateFunc<T, bool>Predicate function to test the value.
operationFunc<T, ValueTask<Result<T>>>Async operation to execute if predicate is true.
Returns
- ValueTask<Result<T>>
Result from the operation if predicate is true and result is success; otherwise the original result.
Type Parameters
TType of the result value.