Table of Contents

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

result Result<T>

The result to test.

condition bool

Boolean condition.

operation Func<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

T

Type 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

result Result<T>

The result to test.

predicate Func<T, bool>

Predicate function to test the value.

operation Func<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

T

Type 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

resultTask Task<Result<T>>

Task containing the result to test.

condition bool

Boolean condition.

operation Func<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

T

Type 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

resultTask Task<Result<T>>

Task containing the result to test.

predicate Func<T, bool>

Predicate function to test the value.

operation Func<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

T

Type 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

resultTask ValueTask<Result<T>>

ValueTask containing the result to test.

predicate Func<T, bool>

Predicate function to test the value.

operation Func<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

T

Type 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

result Result<T>

The result to test.

condition bool

Boolean condition.

operation Func<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

T

Type 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

result Result<T>

The result to test.

predicate Func<T, bool>

Predicate function to test the value.

operation Func<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

T

Type 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

resultTask Task<Result<T>>

Task containing the result to test.

condition bool

Boolean condition.

operation Func<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

T

Type 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

resultTask Task<Result<T>>

Task containing the result to test.

predicate Func<T, bool>

Predicate function to test the value.

operation Func<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

T

Type 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

resultTask ValueTask<Result<T>>

ValueTask containing the result to test.

predicate Func<T, bool>

Predicate function to test the value.

operation Func<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

T

Type of the result value.