Class ResultOrExtensions
Extension methods for providing fallback results on failure.
public static class ResultOrExtensions
- Inheritance
-
ResultOrExtensions
- Inherited Members
Methods
Or(Result, Result)
Returns the result if successful; otherwise returns the provided fallback.
public static Result Or(this Result result, Result fallback)
Parameters
Returns
- Result
The original result if successful; otherwise
fallback.
OrElse(Result, Func<ImmutableList<IError>, Result>)
Returns the result if successful; otherwise invokes the fallback factory with the current errors.
public static Result OrElse(this Result result, Func<ImmutableList<IError>, Result> fallbackFactory)
Parameters
resultResultThe result to check.
fallbackFactoryFunc<ImmutableList<IError>, Result>Function that receives the current errors and produces a fallback result.
Returns
- Result
The original result if successful; otherwise the result of
fallbackFactory.
OrElseAsync(Result, Func<ImmutableList<IError>, Task<Result>>, CancellationToken)
Returns the result if successful; otherwise asynchronously invokes the fallback factory with the current errors.
public static Task<Result> OrElseAsync(this Result result, Func<ImmutableList<IError>, Task<Result>> fallbackFactory, CancellationToken cancellationToken = default)
Parameters
resultResultThe result to check.
fallbackFactoryFunc<ImmutableList<IError>, Task<Result>>Async function that receives the current errors and produces a fallback result.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
OrElseAsync<T>(Result<T>, Func<ImmutableList<IError>, Task<Result<T>>>, CancellationToken)
Returns the result if successful; otherwise asynchronously invokes the fallback factory with the current errors.
public static Task<Result<T>> OrElseAsync<T>(this Result<T> result, Func<ImmutableList<IError>, Task<Result<T>>> fallbackFactory, CancellationToken cancellationToken = default)
Parameters
resultResult<T>The result to check.
fallbackFactoryFunc<ImmutableList<IError>, Task<Result<T>>>Async function that receives the current errors and produces a fallback result.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
Type Parameters
TThe value type.
OrElse<T>(Result<T>, Func<ImmutableList<IError>, Result<T>>)
Returns the result if successful; otherwise invokes the fallback factory with the current errors.
public static Result<T> OrElse<T>(this Result<T> result, Func<ImmutableList<IError>, Result<T>> fallbackFactory)
Parameters
resultResult<T>The result to check.
fallbackFactoryFunc<ImmutableList<IError>, Result<T>>Function that receives the current errors and produces a fallback result.
Returns
- Result<T>
The original result if successful; otherwise the result of
fallbackFactory.
Type Parameters
TThe value type.
Or<T>(Result<T>, Result<T>)
Returns the result if successful; otherwise returns the provided fallback.
public static Result<T> Or<T>(this Result<T> result, Result<T> fallback)
Parameters
Returns
- Result<T>
The original result if successful; otherwise
fallback.
Type Parameters
TThe value type.