Class ResultExtensions
public static class ResultExtensions
- Inheritance
-
ResultExtensions
- Inherited Members
Methods
Bind<TSource, TDestination>(Result<TSource>, Func<TSource, Result<TDestination>>)
Maps the value of a successful Result<T> using a function that itself returns a result.
public static Result<TDestination> Bind<TSource, TDestination>(this Result<TSource> result, Func<TSource, Result<TDestination>> bind)
Parameters
resultResult<TSource>The result to bind.
bindFunc<TSource, Result<TDestination>>The function to apply to the value, returning a new result.
Returns
- Result<TDestination>
The result of the bind function, or the original problems on failure.
Type Parameters
TSourceThe source value type.
TDestinationThe destination value type.
DiscardResult(Result)
Explicitly discards a Result, signalling that its success or failure is
intentionally not observed. Use this to satisfy the unobserved-result analyzer (EPC13)
when ignoring a result is deliberate, e.g. (await CreateUser(request)).DiscardResult();.
public static void DiscardResult(this Result result)
Parameters
resultResultThe result to discard.
DiscardResult<T>(Result<T>)
Explicitly discards a Result<T>, signalling that its success or failure is
intentionally not observed. Use this to satisfy the unobserved-result analyzer (EPC13)
when ignoring a result is deliberate, e.g. (await CreateUser(request)).DiscardResult();.
public static void DiscardResult<T>(this Result<T> result)
Parameters
resultResult<T>The result to discard.
Type Parameters
TThe type of the discarded value.
Map<TSource, TDestination>(Result<TSource>, Func<TSource, TDestination>)
Maps the value of a successful Result<T> using the specified mapping function.
public static Result<TDestination> Map<TSource, TDestination>(this Result<TSource> result, Func<TSource, TDestination> map)
Parameters
resultResult<TSource>The result to map.
mapFunc<TSource, TDestination>The function to apply to the value.
Returns
- Result<TDestination>
A new result with the mapped value, or the original problems on failure.
Type Parameters
TSourceThe source value type.
TDestinationThe destination value type.
ToEmptyResult<T>(Result<T>)
Discards the value of a Result<T>, keeping only the success/failure status.
public static Result ToEmptyResult<T>(this Result<T> result)
Parameters
resultResult<T>The result to convert.
Returns
Type Parameters
TThe type of the discarded value.
WithValueOnSuccess<T>(Result, T)
public static Result<T> WithValueOnSuccess<T>(this Result result, T value)
Parameters
resultResultThe result to attach a value to.
valueTThe value to attach on success.
Returns
Type Parameters
TThe type of the value.