Skip to main content

ResultMatchExtensions

Namespace: Bogoware.Monads

public static class ResultMatchExtensions

Inheritance ObjectResultMatchExtensions
Attributes NullableContextAttribute, NullableAttribute, ExtensionAttribute

Methods

Match<TValue, TResult>(Result<TValue>, TResult, TResult)

public static TResult Match<TValue, TResult>(Result<TValue> result, TResult successful, TResult failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful TResult

failure TResult

Returns

TResult

Match<TValue, TResult>(Result<TValue>, Func<TResult>, TResult)

public static TResult Match<TValue, TResult>(Result<TValue> result, Func<TResult> successful, TResult failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TResult>

failure TResult

Returns

TResult

Match<TValue, TResult>(Result<TValue>, Func<Task<TResult>>, TResult)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, Func<Task<TResult>> successful, TResult failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<Task<TResult>>

failure TResult

Returns

Task<TResult>

Match<TValue, TResult>(Result<TValue>, TResult, Func<TResult>)

public static TResult Match<TValue, TResult>(Result<TValue> result, TResult successful, Func<TResult> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful TResult

failure Func<TResult>

Returns

TResult

Match<TValue, TResult>(Result<TValue>, TResult, Func<Task<TResult>>)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, TResult successful, Func<Task<TResult>> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful TResult

failure Func<Task<TResult>>

Returns

Task<TResult>

Match<TValue, TResult>(Result<TValue>, Func<TResult>, Func<TResult>)

public static TResult Match<TValue, TResult>(Result<TValue> result, Func<TResult> successful, Func<TResult> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TResult>

failure Func<TResult>

Returns

TResult

Match<TValue, TResult>(Result<TValue>, Func<TValue, TResult>, TResult)

public static TResult Match<TValue, TResult>(Result<TValue> result, Func<TValue, TResult> successful, TResult failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TValue, TResult>

failure TResult

Returns

TResult

Match<TValue, TResult>(Result<TValue>, Func<TValue, TResult>, Func<TResult>)

public static TResult Match<TValue, TResult>(Result<TValue> result, Func<TValue, TResult> successful, Func<TResult> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TValue, TResult>

failure Func<TResult>

Returns

TResult

Match<TValue, TResult>(Result<TValue>, Func<TValue, TResult>, Func<Task<TResult>>)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, Func<TValue, TResult> successful, Func<Task<TResult>> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TValue, TResult>

failure Func<Task<TResult>>

Returns

Task<TResult>

Match<TValue, TResult>(Result<TValue>, TResult, Func<Error, Task<TResult>>)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, TResult successful, Func<Error, Task<TResult>> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful TResult

failure Func<Error, Task<TResult>>

Returns

Task<TResult>

Match<TValue, TResult>(Result<TValue>, Func<TResult>, Func<Error, Task<TResult>>)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, Func<TResult> successful, Func<Error, Task<TResult>> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TResult>

failure Func<Error, Task<TResult>>

Returns

Task<TResult>

Match<TValue, TResult>(Result<TValue>, Func<TValue, Task<TResult>>, TResult)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, Func<TValue, Task<TResult>> successful, TResult failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TValue, Task<TResult>>

failure TResult

Returns

Task<TResult>

Match<TValue, TResult>(Result<TValue>, Func<TValue, Task<TResult>>, Func<TResult>)

public static Task<TResult> Match<TValue, TResult>(Result<TValue> result, Func<TValue, Task<TResult>> successful, Func<TResult> failure)

Type Parameters

TValue

TResult

Parameters

result Result<TValue>

successful Func<TValue, Task<TResult>>

failure Func<TResult>

Returns

Task<TResult>

GetValue<TValue>(Result<TValue>, TValue)

Retrieve the value if Result<TValue>.IsSuccess or return the recoverValue if Result<TValue>.IsFailure.

public static TValue GetValue<TValue>(Result<TValue> result, TValue recoverValue)

Type Parameters

TValue

Parameters

result Result<TValue>

recoverValue TValue

Returns

TValue

GetValue<TValue>(Result<TValue>, Func<TValue>)

public static TValue GetValue<TValue>(Result<TValue> result, Func<TValue> recoverValue)

Type Parameters

TValue

Parameters

result Result<TValue>

recoverValue Func<TValue>

Returns

TValue

GetValue<TValue>(Result<TValue>, Func<Task<TValue>>)

public static Task<TValue> GetValue<TValue>(Result<TValue> result, Func<Task<TValue>> recoverValue)

Type Parameters

TValue

Parameters

result Result<TValue>

recoverValue Func<Task<TValue>>

Returns

Task<TValue>