Repository navigation
OnixLabs.Core.ResultExtensions
Provides extension methods for Result and Result<T> instances, including asynchronous combinators over Task<Result>, Task<Result<T>>, ValueTask<Result>, and ValueTask<Result<T>>, Optional<T>-bridging helpers, and failure conversions.
| Namespace | OnixLabs.Core |
| Assembly | OnixLabs.Core.dll (NuGet) |
| Inheritance |
object → ResultExtensions
|
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ResultExtensionsNote
ResultExtensionsis decorated with[EditorBrowsable(EditorBrowsableState.Never)], so the class itself is hidden from IntelliSense completion lists. Its extension methods are fully callable; they appear on their receiver types at the call site as normal.
All members are declared in C# 14 extension blocks, one block per receiver type. Each member is shown below in its equivalent classic static-extension-method form, with the block's receiver as the leading this parameter named receiver; at the call site they are invoked as instance methods on the receiver.
The members fall into three categories:
-
Async combinators over
Task<Result>,Task<Result<T>>,ValueTask<Result>, andValueTask<Result<T>>. These await the receiver and then apply the corresponding synchronous or asynchronous combinator ofResultorResult<T>, so that a pipeline can be composed without intermediateawaitexpressions. -
Optional<T>bridging overResult<T>,Result<Optional<T>>, and theirTask/ValueTaskforms. -
Failure conversions over
Task<Failure>,Task<Failure<T>>, and theirValueTaskforms.
The return type follows the receiver: every member on a Task<…> receiver returns Task or Task<…> (110 members), and every member on a ValueTask<…> receiver returns ValueTask or ValueTask<…> (110 members). Every asynchronous member accepts a trailing CancellationToken cancellationToken = default, the token to monitor for cancellation requests; it is observed while awaiting the receiver and is passed to any delegate that accepts a CancellationToken.
Within each receiver, the combinators MatchAsync, SelectAsync, and SelectManyAsync accept synchronous delegates, Task-returning delegates, and ValueTask-returning delegates, each with and without a CancellationToken parameter.
Overload resolution note Where both a
Task-returning and aValueTask-returning delegate overload exist, anasynclambda (or a lambda whose body is only athrowexpression) is convertible to both delegate types, so the call is ambiguous and fails with compiler error CS0121. Give the lambda an explicit return type to select an overload, for exampleasync Task<Result> (_) => ...orasync ValueTask (value) => .... Method groups and non-asynclambdas that return an existingTask/ValueTaskresolve without annotation.
using OnixLabs.Core;
Task<Result> work = Result.OfAsync(() => SaveAsync(entity));
await work.MatchAsync(
success: () => Console.WriteLine("Saved."),
failure: exception => Console.WriteLine($"Failed: {exception.Message}"));using OnixLabs.Core;
Task<Result<User>> fetch = Result<User>.OfAsync(token => FetchUserAsync(id, token), cancellationToken);
string name = await fetch.MatchAsync(
success: user => user.Name,
failure: _ => "(unknown)",
cancellationToken: cancellationToken);ValueTask<Result<User>> pending = LoadUserAsync(id); // returns ValueTask<Result<User>>
Result<Profile> profile = await pending.SelectAsync(
async ValueTask<Profile> (user) => await profiles.GetAsync(user.Id));Optional<User> maybeUser = await fetch.GetValueOrNoneAsync();string greeting = await Result<string>
.OfAsync(() => ReadInputAsync())
.SelectAsync(s => s.Trim())
.SelectAsync(s => $"Hello, {s}!")
.MatchAsync(
success: msg => msg,
failure: _ => "Hello, stranger!");The methods are grouped by receiver type. Select a method to view its full signature and parameters.
Synchronous Optional<T> bridging for a Result<T> whose value type is non-nullable (T : notnull).
| Method | Returns | Description |
|---|---|---|
GetValueOrNone() |
Optional<T> |
Gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state. |
Synchronous helpers for a Result<T> that wraps an Optional<T>.
| Method | Returns | Description |
|---|---|---|
GetOptionalValueOrDefault(T) |
T |
Gets the underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
GetOptionalValueOrThrow() |
T |
Gets the underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
GetValueOrNone() |
Optional<T> |
Gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state. |
Each member awaits the Task (observing cancellationToken where present) and delegates to the corresponding synchronous member of Result. All members return Task/Task<TResult>.
| Method | Returns | Description |
|---|---|---|
GetExceptionOrDefaultAsync(CancellationToken) |
Task<Exception?> |
Asynchronously gets the underlying exception if the current Result is in a Failure state, or null if the current Result is in a Success state. |
GetExceptionOrDefaultAsync(Exception, CancellationToken) |
Task<Exception> |
Asynchronously gets the underlying exception if the current Result is in a Failure state, or the specified default exception if the current Result is in a Success state. |
GetExceptionOrThrowAsync(CancellationToken) |
Task<Exception> |
Asynchronously gets the underlying exception if the current Result is in a Failure state, or throws InvalidOperationException if the current Result is in a Success state. |
MatchAsync(Action?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: synchronous. |
MatchAsync(Func<Task>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync(Func<ValueTask>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync(Func<CancellationToken, Task>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync(Func<CancellationToken, ValueTask>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync(Action?, Func<Exception, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync(Action?, Func<Exception, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync(Action?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync(Action?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync(Func<Task>?, Func<Exception, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync(Func<ValueTask>?, Func<Exception, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync(Func<CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync(Func<CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<TResult>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: synchronous. |
MatchAsync<TResult>(Func<Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync<TResult>(Func<ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<TResult>, Func<Exception, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync<TResult>(Func<TResult>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<Task<TResult>>, Func<Exception, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync<TResult>(Func<ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
SelectAsync(Action, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectAsync(Func<Task>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectAsync(Func<ValueTask>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectAsync(Func<CancellationToken, Task>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync(Func<CancellationToken, ValueTask>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectAsync<TResult>(Func<TResult>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectAsync<TResult>(Func<Task<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectAsync<TResult>(Func<ValueTask<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync(Func<Result>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectManyAsync(Func<Task<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectManyAsync(Func<ValueTask<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync(Func<CancellationToken, Task<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync(Func<CancellationToken, ValueTask<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync<TResult>(Func<Result<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectManyAsync<TResult>(Func<Task<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectManyAsync<TResult>(Func<ValueTask<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync<TResult>(Func<CancellationToken, Task<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync<TResult>(Func<CancellationToken, ValueTask<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
ThrowAsync(CancellationToken) |
Task |
Asynchronously throws the underlying exception if the current Result is in a failure state. |
Each member awaits the Task (observing cancellationToken where present) and delegates to the corresponding synchronous member of Result<T>. All members return Task/Task<TResult>. GetValueOrNoneAsync additionally requires T : notnull.
| Method | Returns | Description |
|---|---|---|
GetExceptionOrDefaultAsync(CancellationToken) |
Task<Exception?> |
Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or null if the current Result<T> is in a Success<T> state. |
GetExceptionOrDefaultAsync(Exception, CancellationToken) |
Task<Exception> |
Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or the specified default exception if the current Result<T> is in a Success<T> state. |
GetExceptionOrThrowAsync(CancellationToken) |
Task<Exception> |
Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or throws InvalidOperationException if the current Result<T> is in a Success<T> state. |
GetValueOrDefaultAsync(CancellationToken) |
Task<T?> |
Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the default T value. |
GetValueOrDefaultAsync(T, CancellationToken) |
Task<T> |
Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the specified default value. |
GetValueOrNoneAsync(CancellationToken) |
Task<Optional<T>> |
Asynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state. |
GetValueOrThrowAsync(CancellationToken) |
Task<T> |
Asynchronously gets the underlying value of the current Result<T> instance; otherwise throws the underlying exception if the current Result<T> is in a failed stated. |
MatchAsync(Action<T>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: synchronous. |
MatchAsync(Func<T, Task>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync(Func<T, ValueTask>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync(Func<T, CancellationToken, Task>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync(Func<T, CancellationToken, ValueTask>?, Action<Exception>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync(Action<T>?, Func<Exception, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync(Action<T>?, Func<Exception, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync(Action<T>?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync(Action<T>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync(Func<T, Task>?, Func<Exception, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync(Func<T, ValueTask>?, Func<Exception, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync(Func<T, CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
Task |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: synchronous. |
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Exception, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
Task<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
SelectAsync(Action<T>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectAsync(Func<T, Task>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectAsync(Func<T, ValueTask>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectAsync(Func<T, CancellationToken, Task>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync(Func<T, CancellationToken, ValueTask>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectAsync<TResult>(Func<T, TResult>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectAsync<TResult>(Func<T, Task<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectAsync<TResult>(Func<T, ValueTask<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync(Func<T, Result>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectManyAsync(Func<T, Task<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectManyAsync(Func<T, ValueTask<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync(Func<T, CancellationToken, Task<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync(Func<T, CancellationToken, ValueTask<Result>>, CancellationToken) |
Task<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync<TResult>(Func<T, Result<TResult>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectManyAsync<TResult>(Func<T, Task<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectManyAsync<TResult>(Func<T, ValueTask<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync<TResult>(Func<T, CancellationToken, Task<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync<TResult>(Func<T, CancellationToken, ValueTask<Result<TResult>>>, CancellationToken) |
Task<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
ThrowAsync(CancellationToken) |
Task |
Asynchronously throws the underlying exception if the current Result<T> is in a failure state. |
Awaits the Task and bridges the wrapped Optional<T>. All members return Task/Task<TResult>.
| Method | Returns | Description |
|---|---|---|
GetOptionalValueOrDefaultAsync(T, CancellationToken) |
Task<T> |
Asynchronously gets the underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
GetOptionalValueOrThrowAsync(CancellationToken) |
Task<T> |
Asynchronously gets the underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
GetValueOrNoneAsync(CancellationToken) |
Task<Optional<T>> |
Asynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state. |
Awaits the Task and converts the Failure. Returns Task<…>.
| Method | Returns | Description |
|---|---|---|
ToTypedResultAsync<TResult>(CancellationToken) |
Task<Failure<TResult>> |
Asynchronously obtains a new Failure<T> instance containing the current exception. |
Awaits the Task and converts the Failure<T>. Returns Task<…>.
| Method | Returns | Description |
|---|---|---|
ToTypedResultAsync<TResult>(CancellationToken) |
Task<Failure<TResult>> |
Asynchronously obtains a new Failure<T> instance containing the current exception. |
ToUntypedResultAsync(CancellationToken) |
Task<Failure> |
Asynchronously obtains a new Failure instance containing the current exception. |
Each member awaits the ValueTask (observing cancellationToken where present) and delegates to the corresponding synchronous member of Result. All members return ValueTask/ValueTask<TResult>.
| Method | Returns | Description |
|---|---|---|
GetExceptionOrDefaultAsync(CancellationToken) |
ValueTask<Exception?> |
Asynchronously gets the underlying exception if the current Result is in a Failure state, or null if the current Result is in a Success state. |
GetExceptionOrDefaultAsync(Exception, CancellationToken) |
ValueTask<Exception> |
Asynchronously gets the underlying exception if the current Result is in a Failure state, or the specified default exception if the current Result is in a Success state. |
GetExceptionOrThrowAsync(CancellationToken) |
ValueTask<Exception> |
Asynchronously gets the underlying exception if the current Result is in a Failure state, or throws InvalidOperationException if the current Result is in a Success state. |
MatchAsync(Action?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: synchronous. |
MatchAsync(Func<Task>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync(Func<ValueTask>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync(Func<CancellationToken, Task>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync(Func<CancellationToken, ValueTask>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync(Action?, Func<Exception, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync(Action?, Func<Exception, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync(Action?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync(Action?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync(Func<Task>?, Func<Exception, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync(Func<ValueTask>?, Func<Exception, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync(Func<CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync(Func<CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result instance. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<TResult>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: synchronous. |
MatchAsync<TResult>(Func<Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync<TResult>(Func<ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<TResult>, Func<Exception, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync<TResult>(Func<TResult>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<Task<TResult>>, Func<Exception, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync<TResult>(Func<ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
SelectAsync(Action, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectAsync(Func<Task>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectAsync(Func<ValueTask>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectAsync(Func<CancellationToken, Task>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync(Func<CancellationToken, ValueTask>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectAsync<TResult>(Func<TResult>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectAsync<TResult>(Func<Task<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectAsync<TResult>(Func<ValueTask<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync(Func<Result>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectManyAsync(Func<Task<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectManyAsync(Func<ValueTask<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync(Func<CancellationToken, Task<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync(Func<CancellationToken, ValueTask<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync<TResult>(Func<Result<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: synchronous. |
SelectManyAsync<TResult>(Func<Task<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning. |
SelectManyAsync<TResult>(Func<ValueTask<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync<TResult>(Func<CancellationToken, Task<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync<TResult>(Func<CancellationToken, ValueTask<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result instance. Delegates — selector: ValueTask-returning (cancellable). |
ThrowAsync(CancellationToken) |
ValueTask |
Asynchronously throws the underlying exception if the current Result is in a failure state. |
Each member awaits the ValueTask (observing cancellationToken where present) and delegates to the corresponding synchronous member of Result<T>. All members return ValueTask/ValueTask<TResult>. GetValueOrNoneAsync additionally requires T : notnull.
| Method | Returns | Description |
|---|---|---|
GetExceptionOrDefaultAsync(CancellationToken) |
ValueTask<Exception?> |
Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or null if the current Result<T> is in a Success<T> state. |
GetExceptionOrDefaultAsync(Exception, CancellationToken) |
ValueTask<Exception> |
Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or the specified default exception if the current Result<T> is in a Success<T> state. |
GetExceptionOrThrowAsync(CancellationToken) |
ValueTask<Exception> |
Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or throws InvalidOperationException if the current Result<T> is in a Success<T> state. |
GetValueOrDefaultAsync(CancellationToken) |
ValueTask<T?> |
Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the default T value. |
GetValueOrDefaultAsync(T, CancellationToken) |
ValueTask<T> |
Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the specified default value. |
GetValueOrNoneAsync(CancellationToken) |
ValueTask<Optional<T>> |
Asynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state. |
GetValueOrThrowAsync(CancellationToken) |
ValueTask<T> |
Asynchronously gets the underlying value of the current Result<T> instance; otherwise throws the underlying exception if the current Result<T> is in a failed stated. |
MatchAsync(Action<T>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: synchronous. |
MatchAsync(Func<T, Task>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync(Func<T, ValueTask>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync(Func<T, CancellationToken, Task>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync(Func<T, CancellationToken, ValueTask>?, Action<Exception>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync(Action<T>?, Func<Exception, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync(Action<T>?, Func<Exception, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync(Action<T>?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync(Action<T>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync(Func<T, Task>?, Func<Exception, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync(Func<T, ValueTask>?, Func<Exception, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync(Func<T, CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken) |
ValueTask |
Asynchronously executes the delegate that matches the value of the current Result<T> instance. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: synchronous. |
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning; failure: synchronous. |
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning; failure: synchronous. |
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: synchronous. |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: Task-returning. |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: synchronous; failure: ValueTask-returning (cancellable). |
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Exception, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning; failure: Task-returning. |
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning; failure: ValueTask-returning. |
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: Task-returning (cancellable); failure: Task-returning (cancellable). |
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken) |
ValueTask<TResult> |
Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result. Delegates — success: ValueTask-returning (cancellable); failure: ValueTask-returning (cancellable). |
SelectAsync(Action<T>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectAsync(Func<T, Task>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectAsync(Func<T, ValueTask>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectAsync(Func<T, CancellationToken, Task>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync(Func<T, CancellationToken, ValueTask>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectAsync<TResult>(Func<T, TResult>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectAsync<TResult>(Func<T, Task<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectAsync<TResult>(Func<T, ValueTask<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync(Func<T, Result>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectManyAsync(Func<T, Task<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectManyAsync(Func<T, ValueTask<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync(Func<T, CancellationToken, Task<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync(Func<T, CancellationToken, ValueTask<Result>>, CancellationToken) |
ValueTask<Result> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
SelectManyAsync<TResult>(Func<T, Result<TResult>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: synchronous. |
SelectManyAsync<TResult>(Func<T, Task<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning. |
SelectManyAsync<TResult>(Func<T, ValueTask<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning. |
SelectManyAsync<TResult>(Func<T, CancellationToken, Task<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: Task-returning (cancellable). |
SelectManyAsync<TResult>(Func<T, CancellationToken, ValueTask<Result<TResult>>>, CancellationToken) |
ValueTask<Result<TResult>> |
Asynchronously applies the provided selector delegate to the value of the current Result<T> instance. Delegates — selector: ValueTask-returning (cancellable). |
ThrowAsync(CancellationToken) |
ValueTask |
Asynchronously throws the underlying exception if the current Result<T> is in a failure state. |
Awaits the ValueTask and bridges the wrapped Optional<T>. All members return ValueTask/ValueTask<TResult>.
| Method | Returns | Description |
|---|---|---|
GetOptionalValueOrDefaultAsync(T, CancellationToken) |
ValueTask<T> |
Asynchronously gets the underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
GetOptionalValueOrThrowAsync(CancellationToken) |
ValueTask<T> |
Asynchronously gets the underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
GetValueOrNoneAsync(CancellationToken) |
ValueTask<Optional<T>> |
Asynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state. |
Awaits the ValueTask and converts the Failure. Returns ValueTask<…>.
| Method | Returns | Description |
|---|---|---|
ToTypedResultAsync<TResult>(CancellationToken) |
ValueTask<Failure<TResult>> |
Asynchronously obtains a new Failure<T> instance containing the current exception. |
Awaits the ValueTask and converts the Failure<T>. Returns ValueTask<…>.
| Method | Returns | Description |
|---|---|---|
ToTypedResultAsync<TResult>(CancellationToken) |
ValueTask<Failure<TResult>> |
Asynchronously obtains a new Failure<T> instance containing the current exception. |
ToUntypedResultAsync(CancellationToken) |
ValueTask<Failure> |
Asynchronously obtains a new Failure instance containing the current exception. |
public static Optional<T> GetValueOrNone<T>(this Result<T> receiver) where T : notnullGets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Result<T> |
The current Result<T> instance. |
Returns — Optional<T>. The Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
public static T GetOptionalValueOrDefault<T>(this Result<Optional<T>> receiver, T defaultValue) where T : notnullGets the underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Result<Optional<T>> |
The current Result<Optional<T>> instance. |
defaultValue |
T |
The default value to return if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
Returns — T. The underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
public static T GetOptionalValueOrThrow<T>(this Result<Optional<T>> receiver) where T : notnullGets the underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Result<Optional<T>> |
The current Result<Optional<T>> instance. |
Returns — T. The underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
public static Optional<T> GetValueOrNone<T>(this Result<Optional<T>> receiver) where T : notnullGets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Result<Optional<T>> |
The current Result<Optional<T>> instance. |
Returns — Optional<T>. The Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
public static async Task<Exception?> GetExceptionOrDefaultAsync(this Task<Result> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result is in a Failure state, or null if the current Result is in a Success state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Exception?>. The underlying exception if the current Result is in a Failure state, or null if the current Result is in a Success state.
public static async Task<Exception> GetExceptionOrDefaultAsync(this Task<Result> receiver, Exception defaultException, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result is in a Failure state, or the specified default exception if the current Result is in a Success state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
defaultException |
Exception |
The default exception to return in the event that the current Result is in a Success state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Exception>. The underlying exception if the current Result is in a Failure state, or the specified default exception if the current Result is in a Success state.
public static async Task<Exception> GetExceptionOrThrowAsync(this Task<Result> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result is in a Failure state, or throws InvalidOperationException if the current Result is in a Success state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Exception>. The underlying exception if the current Result is in a Failure state, or throws InvalidOperationException if the current Result is in a Success state.
public static async Task MatchAsync(this Task<Result> receiver, Action? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Func<Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Func<ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Func<CancellationToken, Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Func<CancellationToken, ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Action? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Action? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Action? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Action? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Func<Task>? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync(this Task<Result> receiver, Func<ValueTask>? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
MatchAsync(Func<CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken)
public static async Task MatchAsync(this Task<Result> receiver, Func<CancellationToken, Task>? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
MatchAsync(Func<CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken)
public static async Task MatchAsync(this Task<Result> receiver, Func<CancellationToken, ValueTask>? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<TResult> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<TResult> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<TResult> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<TResult> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<TResult> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<Task<TResult>> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<ValueTask<TResult>> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, Task<TResult>> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, ValueTask<TResult>> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
success |
Func<CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async Task<Result> SelectAsync(this Task<Result> receiver, Action selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Action |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync(this Task<Result> receiver, Func<Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<Task> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync(this Task<Result> receiver, Func<ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<ValueTask> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync(this Task<Result> receiver, Func<CancellationToken, Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, Task> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync(this Task<Result> receiver, Func<CancellationToken, ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, ValueTask> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result<TResult>> SelectAsync<TResult>(this Task<Result> receiver, Func<TResult> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<TResult> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<TResult>(this Task<Result> receiver, Func<Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<Task<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<TResult>(this Task<Result> receiver, Func<ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<ValueTask<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, Task<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, ValueTask<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result> SelectManyAsync(this Task<Result> receiver, Func<Result> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<Result> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync(this Task<Result> receiver, Func<Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<Task<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync(this Task<Result> receiver, Func<ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<ValueTask<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync(this Task<Result> receiver, Func<CancellationToken, Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, Task<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync(this Task<Result> receiver, Func<CancellationToken, ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, ValueTask<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result<TResult>> SelectManyAsync<TResult>(this Task<Result> receiver, Func<Result<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<Result<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<TResult>(this Task<Result> receiver, Func<Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<Task<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<TResult>(this Task<Result> receiver, Func<ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<ValueTask<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, Task<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<TResult>(this Task<Result> receiver, Func<CancellationToken, ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
selector |
Func<CancellationToken, ValueTask<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task ThrowAsync(this Task<Result> receiver, CancellationToken cancellationToken = default)Asynchronously throws the underlying exception if the current Result is in a failure state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result> |
The current Task<Result> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task<Exception?> GetExceptionOrDefaultAsync<T>(this Task<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or null if the current Result<T> is in a Success<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Exception?>. The underlying exception if the current Result<T> is in a Failure<T> state, or null if the current Result<T> is in a Success<T> state.
public static async Task<Exception> GetExceptionOrDefaultAsync<T>(this Task<Result<T>> receiver, Exception defaultException, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or the specified default exception if the current Result<T> is in a Success<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
defaultException |
Exception |
The default exception to return in the event that the current Result<T> is in a Success<T> state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Exception>. The underlying exception if the current Result<T> is in a Failure<T> state, or the specified default exception if the current Result<T> is in a Success<T> state.
public static async Task<Exception> GetExceptionOrThrowAsync<T>(this Task<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or throws InvalidOperationException if the current Result<T> is in a Success<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Exception>. The underlying exception if the current Result<T> is in a Failure<T> state, or throws InvalidOperationException if the current Result<T> is in a Success<T> state.
public static async Task<T?> GetValueOrDefaultAsync<T>(this Task<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the default T value.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<T?>. The underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the default T value.
public static async Task<T> GetValueOrDefaultAsync<T>(this Task<Result<T>> receiver, T defaultValue, CancellationToken cancellationToken = default)Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the specified default value.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
defaultValue |
T |
The default value to return in the event that the underlying value is absent. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<T>. The underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the specified default value.
public static async Task<Optional<T>> GetValueOrNoneAsync<T>(this Task<Result<T>> receiver, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Optional<T>>. The Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
public static async Task<T> GetValueOrThrowAsync<T>(this Task<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying value of the current Result<T> instance; otherwise throws the underlying exception if the current Result<T> is in a failed stated.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<T>. The underlying value of the current Result<T> instance; otherwise throws the underlying exception if the current Result<T> is in a failed stated.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Action<T>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Action<T>? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Action<T>? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Action<T>? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Action<T>? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, Task>? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, ValueTask>? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
MatchAsync(Func<T, CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken)
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task>? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken)
public static async Task MatchAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask>? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, TResult> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, TResult> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, TResult> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, TResult> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, TResult> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, Task<TResult>> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, ValueTask<TResult>> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task<TResult>> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async Task<TResult> MatchAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async Task<Result> SelectAsync<T>(this Task<Result<T>> receiver, Action<T> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Action<T> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync<T>(this Task<Result<T>> receiver, Func<T, Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, Task> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync<T>(this Task<Result<T>> receiver, Func<T, ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, ValueTask> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result<TResult>> SelectAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, TResult> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, TResult> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, Task<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, ValueTask<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result> SelectManyAsync<T>(this Task<Result<T>> receiver, Func<T, Result> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, Result> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync<T>(this Task<Result<T>> receiver, Func<T, Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, Task<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync<T>(this Task<Result<T>> receiver, Func<T, ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, ValueTask<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result> SelectManyAsync<T>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async Task<Result<TResult>> SelectManyAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, Result<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, Result<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, Task<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, ValueTask<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task<Result<TResult>> SelectManyAsync<T, TResult>(this Task<Result<T>> receiver, Func<T, CancellationToken, ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async Task ThrowAsync<T>(this Task<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously throws the underlying exception if the current Result<T> is in a failure state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<T>> |
The current Task<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task. A Task that represents the asynchronous operation.
public static async Task<T> GetOptionalValueOrDefaultAsync<T>(this Task<Result<Optional<T>>> receiver, T defaultValue, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<Optional<T>>> |
The current Task<Result<Optional<T>>> instance. |
defaultValue |
T |
The default value to return if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<T>. The underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
public static async Task<T> GetOptionalValueOrThrowAsync<T>(this Task<Result<Optional<T>>> receiver, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<Optional<T>>> |
The current Task<Result<Optional<T>>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<T>. The underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
public static async Task<Optional<T>> GetValueOrNoneAsync<T>(this Task<Result<Optional<T>>> receiver, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Result<Optional<T>>> |
The current Task<Result<Optional<T>>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Optional<T>>. The Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
public static async Task<Failure<TResult>> ToTypedResultAsync<TResult>(this Task<Failure> receiver, CancellationToken cancellationToken = default)Asynchronously obtains a new Failure<T> instance containing the current exception.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the Failure<T> to return. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Failure> |
The current Task<Failure> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Failure<TResult>>. A new Failure<T> instance containing the current exception.
public static async Task<Failure<TResult>> ToTypedResultAsync<T, TResult>(this Task<Failure<T>> receiver, CancellationToken cancellationToken = default)Asynchronously obtains a new Failure<T> instance containing the current exception.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The underlying type of the current failure. |
TResult |
The underlying type of the Failure<T> to return. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Failure<T>> |
The current Task<Failure<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Failure<TResult>>. A new Failure<T> instance containing the current exception.
public static async Task<Failure> ToUntypedResultAsync<T>(this Task<Failure<T>> receiver, CancellationToken cancellationToken = default)Asynchronously obtains a new Failure instance containing the current exception.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The underlying type of the current failure. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Task<Failure<T>> |
The current Task<Failure<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — Task<Failure>. A new Failure instance containing the current exception.
public static async ValueTask<Exception?> GetExceptionOrDefaultAsync(this ValueTask<Result> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result is in a Failure state, or null if the current Result is in a Success state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Exception?>. The underlying exception if the current Result is in a Failure state, or null if the current Result is in a Success state.
public static async ValueTask<Exception> GetExceptionOrDefaultAsync(this ValueTask<Result> receiver, Exception defaultException, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result is in a Failure state, or the specified default exception if the current Result is in a Success state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
defaultException |
Exception |
The default exception to return in the event that the current Result is in a Success state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Exception>. The underlying exception if the current Result is in a Failure state, or the specified default exception if the current Result is in a Success state.
public static async ValueTask<Exception> GetExceptionOrThrowAsync(this ValueTask<Result> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result is in a Failure state, or throws InvalidOperationException if the current Result is in a Success state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Exception>. The underlying exception if the current Result is in a Failure state, or throws InvalidOperationException if the current Result is in a Success state.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Action? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<CancellationToken, Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Action? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Action? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Action? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Action? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Action? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<Task>? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<ValueTask>? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
MatchAsync(Func<CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken)
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<CancellationToken, Task>? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
MatchAsync(Func<CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken)
public static async ValueTask MatchAsync(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask>? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<TResult> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<TResult> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<TResult> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<TResult> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<TResult> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<TResult> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<Task<TResult>> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<ValueTask<TResult>> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, Task<TResult>> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
MatchAsync<TResult>(Func<CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask<TResult>> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
success |
Func<CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result instance is in a failed state.
public static async ValueTask<Result> SelectAsync(this ValueTask<Result> receiver, Action selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Action |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync(this ValueTask<Result> receiver, Func<Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<Task> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync(this ValueTask<Result> receiver, Func<ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<ValueTask> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync(this ValueTask<Result> receiver, Func<CancellationToken, Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, Task> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, ValueTask> |
The delegate to apply to current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result<TResult>> SelectAsync<TResult>(this ValueTask<Result> receiver, Func<TResult> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<TResult> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<TResult>(this ValueTask<Result> receiver, Func<Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<Task<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<TResult>(this ValueTask<Result> receiver, Func<ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<ValueTask<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, Task<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, ValueTask<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result> SelectManyAsync(this ValueTask<Result> receiver, Func<Result> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<Result> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync(this ValueTask<Result> receiver, Func<Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<Task<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync(this ValueTask<Result> receiver, Func<ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<ValueTask<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync(this ValueTask<Result> receiver, Func<CancellationToken, Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, Task<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, ValueTask<Result>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result<TResult>> SelectManyAsync<TResult>(this ValueTask<Result> receiver, Func<Result<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<Result<TResult>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<TResult>(this ValueTask<Result> receiver, Func<Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<Task<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<TResult>(this ValueTask<Result> receiver, Func<ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<ValueTask<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, Task<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<TResult>(this ValueTask<Result> receiver, Func<CancellationToken, ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result instance.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
selector |
Func<CancellationToken, ValueTask<Result<TResult>>> |
The delegate to apply to the current Result instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask ThrowAsync(this ValueTask<Result> receiver, CancellationToken cancellationToken = default)Asynchronously throws the underlying exception if the current Result is in a failure state.
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result> |
The current ValueTask<Result> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask<Exception?> GetExceptionOrDefaultAsync<T>(this ValueTask<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or null if the current Result<T> is in a Success<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Exception?>. The underlying exception if the current Result<T> is in a Failure<T> state, or null if the current Result<T> is in a Success<T> state.
public static async ValueTask<Exception> GetExceptionOrDefaultAsync<T>(this ValueTask<Result<T>> receiver, Exception defaultException, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or the specified default exception if the current Result<T> is in a Success<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
defaultException |
Exception |
The default exception to return in the event that the current Result<T> is in a Success<T> state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Exception>. The underlying exception if the current Result<T> is in a Failure<T> state, or the specified default exception if the current Result<T> is in a Success<T> state.
public static async ValueTask<Exception> GetExceptionOrThrowAsync<T>(this ValueTask<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying exception if the current Result<T> is in a Failure<T> state, or throws InvalidOperationException if the current Result<T> is in a Success<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Exception>. The underlying exception if the current Result<T> is in a Failure<T> state, or throws InvalidOperationException if the current Result<T> is in a Success<T> state.
public static async ValueTask<T?> GetValueOrDefaultAsync<T>(this ValueTask<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the default T value.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<T?>. The underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the default T value.
public static async ValueTask<T> GetValueOrDefaultAsync<T>(this ValueTask<Result<T>> receiver, T defaultValue, CancellationToken cancellationToken = default)Asynchronously gets the underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the specified default value.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
defaultValue |
T |
The default value to return in the event that the underlying value is absent. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<T>. The underlying value of the current Result<T> instance, if the underlying value is present; otherwise returns the specified default value.
public static async ValueTask<Optional<T>> GetValueOrNoneAsync<T>(this ValueTask<Result<T>> receiver, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Optional<T>>. The Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
public static async ValueTask<T> GetValueOrThrowAsync<T>(this ValueTask<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously gets the underlying value of the current Result<T> instance; otherwise throws the underlying exception if the current Result<T> is in a failed stated.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<T>. The underlying value of the current Result<T> instance; otherwise throws the underlying exception if the current Result<T> is in a failed stated.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Action<T>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask>? success = null, Action<Exception>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Action<Exception>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Action<T>? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Action<T>? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Action<T>? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Action<T>? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Action<T>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, Task>? success = null, Func<Exception, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, ValueTask>? success = null, Func<Exception, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
MatchAsync(Func<T, CancellationToken, Task>?, Func<Exception, CancellationToken, Task>?, CancellationToken)
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task>? success = null, Func<Exception, CancellationToken, Task>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<Exception, CancellationToken, ValueTask>?, CancellationToken)
public static async ValueTask MatchAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask>? success = null, Func<Exception, CancellationToken, ValueTask>? failure = null, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask>? |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, TResult> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, TResult>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> success, Func<Exception, TResult> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, TResult> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, TResult> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, TResult> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, TResult> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, TResult>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, TResult> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, TResult> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, Task<TResult>> success, Func<Exception, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<Exception, ValueTask<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, ValueTask<TResult>> success, Func<Exception, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<Exception, CancellationToken, Task<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task<TResult>> success, Func<Exception, CancellationToken, Task<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, Task<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<Exception, CancellationToken, ValueTask<TResult>>, CancellationToken)
public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> success, Func<Exception, CancellationToken, ValueTask<TResult>> failure, CancellationToken cancellationToken = default)Asynchronously executes the delegate that matches the value of the current Result<T> instance and returns its result.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the matching delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
success |
Func<T, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a successful state. |
failure |
Func<Exception, CancellationToken, ValueTask<TResult>> |
The delegate to execute when the current Result<T> instance is in a failed state. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<TResult>. The result of the success delegate if the current Result<T> instance is in a successful state; otherwise, returns the result of the failure delegate if the current Result<T> instance is in a failed state.
public static async ValueTask<Result> SelectAsync<T>(this ValueTask<Result<T>> receiver, Action<T> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Action<T> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync<T>(this ValueTask<Result<T>> receiver, Func<T, Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, Task> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync<T>(this ValueTask<Result<T>> receiver, Func<T, ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, ValueTask> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result<TResult>> SelectAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, TResult> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, TResult> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, Task<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, ValueTask<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result> SelectManyAsync<T>(this ValueTask<Result<T>> receiver, Func<T, Result> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, Result> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync<T>(this ValueTask<Result<T>> receiver, Func<T, Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, Task<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync<T>(this ValueTask<Result<T>> receiver, Func<T, ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, ValueTask<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result> SelectManyAsync<T>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask<Result>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask<Result>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result>. Success if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure.
public static async ValueTask<Result<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, Result<TResult>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, Result<TResult>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, Task<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, ValueTask<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, Task<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, Task<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask<Result<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Result<T>> receiver, Func<T, CancellationToken, ValueTask<Result<TResult>>> selector, CancellationToken cancellationToken = default)Asynchronously applies the provided selector delegate to the value of the current Result<T> instance.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
TResult |
The underlying type of the result produced by the selector delegate. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
selector |
Func<T, CancellationToken, ValueTask<Result<TResult>>> |
The delegate to apply to the value of the current Result<T> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Result<TResult>>. Success<T> if the current Result<T> is in a successful state, and the delegate invocation is also successful; otherwise; Failure<T>.
public static async ValueTask ThrowAsync<T>(this ValueTask<Result<T>> receiver, CancellationToken cancellationToken = default)Asynchronously throws the underlying exception if the current Result<T> is in a failure state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying result value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<T>> |
The current ValueTask<Result<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask. A ValueTask that represents the asynchronous operation.
public static async ValueTask<T> GetOptionalValueOrDefaultAsync<T>(this ValueTask<Result<Optional<T>>> receiver, T defaultValue, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<Optional<T>>> |
The current ValueTask<Result<Optional<T>>> instance. |
defaultValue |
T |
The default value to return if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<T>. The underlying T value from the current Result<T> of Optional<T>, or returns the default value if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
public static async ValueTask<T> GetOptionalValueOrThrowAsync<T>(this ValueTask<Result<Optional<T>>> receiver, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<Optional<T>>> |
The current ValueTask<Result<Optional<T>>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<T>. The underlying T value from the current Result<T> of Optional<T>, or throws an exception if the result is in a Failure<T> state, or the Optional<T> is Optional<T>.None.
public static async ValueTask<Optional<T>> GetValueOrNoneAsync<T>(this ValueTask<Result<Optional<T>>> receiver, CancellationToken cancellationToken = default) where T : notnullAsynchronously gets the Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of the underlying optional value. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Result<Optional<T>>> |
The current ValueTask<Result<Optional<T>>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Optional<T>>. The Optional<T> value of the current Result<T> instance, or Optional<T>.None if the result is in a Failure<T> state.
public static async ValueTask<Failure<TResult>> ToTypedResultAsync<TResult>(this ValueTask<Failure> receiver, CancellationToken cancellationToken = default)Asynchronously obtains a new Failure<T> instance containing the current exception.
Type Parameters
| Type Parameter | Description |
|---|---|
TResult |
The underlying type of the Failure<T> to return. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Failure> |
The current ValueTask<Failure> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Failure<TResult>>. A new Failure<T> instance containing the current exception.
public static async ValueTask<Failure<TResult>> ToTypedResultAsync<T, TResult>(this ValueTask<Failure<T>> receiver, CancellationToken cancellationToken = default)Asynchronously obtains a new Failure<T> instance containing the current exception.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The underlying type of the current failure. |
TResult |
The underlying type of the Failure<T> to return. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Failure<T>> |
The current ValueTask<Failure<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Failure<TResult>>. A new Failure<T> instance containing the current exception.
public static async ValueTask<Failure> ToUntypedResultAsync<T>(this ValueTask<Failure<T>> receiver, CancellationToken cancellationToken = default)Asynchronously obtains a new Failure instance containing the current exception.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The underlying type of the current failure. |
Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
ValueTask<Failure<T>> |
The current ValueTask<Failure<T>> instance. |
cancellationToken |
CancellationToken |
The token to monitor for cancellation requests. |
Returns — ValueTask<Failure>. A new Failure instance containing the current exception.
ONIXLabs .NET Library · Repository · NuGet · License (Apache-2.0)
Copyright © ONIXLabs 2020. Licensed under the Apache License, Version 2.0.
- Enumeration<T>
- Optional<T>
- OptionalEqualityComparer<T>
- OptionalExtensions
- Result
- Result<T>
- ResultEqualityComparer<T>
- ResultExtensions
- Specification<T>
- Preconditions
- IValueEquatable<T>
- IValueComparable<T>
- IBinaryConvertible
- ISpanBinaryConvertible
- IMemoryBinaryConvertible
- ArrayExtensions
- ComparableExtensions
- DateTimeExtensions
- ISpanParsableExtensions
- ObjectExtensions
- RandomExtensions
- ReadOnlySequenceExtensions
- ReadOnlySpanExtensions
- StringExtensions
- Base16
- Base32
- Base58
- Base64
- IBaseCodec
- IBaseValue
- IBaseValue<T>
- Base16Codec
- Base32Codec
- Base58Codec
- Base64Codec
- Base16FormatProvider
- Base32FormatProvider
- Base58FormatProvider
- Base64FormatProvider
- EncodingExtensions
- ReadOnlySpanExtensions
- StringBuilderExtensions
- BigDecimal
- BigDecimalEqualityComparer
- BigDecimalOrdinalityComparer
- NumberInfo
- NumberInfoEqualityComparer
- NumberInfoOrdinalityComparer
- Int256
- Int512
- UInt256
- UInt512
- Float128
- Float256
- GenericMath
- NumericsExtensions
- ConversionMode
- ScaleMode
- Hash
- NamedHash
- Sha3
- Sha3Hash224
- Sha3Hash256
- Sha3Hash384
- Sha3Hash512
- Sha3Shake128
- Sha3Shake256
- MerkleTree
- MerkleTree<T>
- PrivateKey
- PublicKey
- NamedPrivateKey
- NamedPublicKey
- EcdhPrivateKey
- EcdhPublicKey
- EcdsaPrivateKey
- EcdsaPublicKey
- EddsaPrivateKey
- EddsaPublicKey
- RsaPrivateKey
- RsaPublicKey
- DigitalSignature
- DigitalSignatureAndPublicKey
- Salt
- Secret
- ICryptoPrimitive<T>
- IHashable
- IEcdhPrivateKey
- IEcdsaPrivateKey
- IEddsaPrivateKey
- IRsaPrivateKey
- IPrivateKeyDerivable<T>
- IPrivateKeyExportable
- IPrivateKeyImportable<T>
- IPrivateKeyPemImportable<T>
- IPrivateKeyPkcs8Exportable
- IPrivateKeyPkcs8Importable<T>
- IPrivateKeyPkcs8PemExportable
- IPrivateKeyRawExportable
- IPrivateKeyRawImportable<T>
- IPrivateKeyRawPemExportable
- IEcdhPublicKey
- IEcdsaPublicKey
- IEddsaPublicKey
- IRsaPublicKey
- IPublicKeyExportable
- IPublicKeyImportable<T>
- IPublicKeyPemExportable
- IPublicKeyPemImportable<T>
- IPublicKeyRawExportable
- IPublicKeyRawImportable<T>
- HashAlgorithmExtensions
- ReadOnlySpanExtensions