Class MatchExtensions
- Namespace
- FunctionalDdd
- Assembly
- FunctionalDdd.RailwayOrientedProgramming.dll
Pattern matching helpers (Match / Switch) for Result.
public static class MatchExtensions
- Inheritance
-
MatchExtensions
- Inherited Members
Methods
Match<TIn, TOut>(Result<TIn>, Func<TIn, TOut>, Func<Error, TOut>)
Executes either the success or failure function based on the result state.
public static TOut Match<TIn, TOut>(this Result<TIn> result, Func<TIn, TOut> onSuccess, Func<Error, TOut> onFailure)
Parameters
resultResult<TIn>The result to match on.
onSuccessFunc<TIn, TOut>Function to execute on success.
onFailureFunc<Error, TOut>Function to execute on failure.
Returns
- TOut
The output from either the success or failure function.
Type Parameters
TInType of the result value.
TOutType of the output.
Switch<TIn>(Result<TIn>, Action<TIn>, Action<Error>)
Executes either the success or failure action based on the result state.
public static void Switch<TIn>(this Result<TIn> result, Action<TIn> onSuccess, Action<Error> onFailure)
Parameters
resultResult<TIn>The result to switch on.
onSuccessAction<TIn>Action to execute on success.
onFailureAction<Error>Action to execute on failure.
Type Parameters
TInType of the result value.