Method FromTryGet
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
FromTryGet<TResult>(TryGet<TResult>)
Runs a method of the bool Try...(out TResult) shape and returns what
it produced.
[Pure]
public static Maybe<TResult> FromTryGet<TResult>(TryGet<TResult> tryGet)
Parameters
tryGetTryGet<TResult>The method to run.
Returns
- Maybe<TResult>
A Maybe<T> containing the output of
tryGetif it returned true, and one containing no value otherwise.
Type Parameters
TResultThe type of the value the method produces.
Remarks
The wrappers this library ships - on StringExtensionMethods and ReadOnlyDictionaryExtensionMethods - cover the usual conditions. This is for the ones it does not know about: your own, or a different library.
FromTryGet<T, TResult>(T, TryGet<T, TResult>)
Runs a method of the bool Try...(T, out TResult) shape against the
given input and returns what it produced.
[Pure]
public static Maybe<TResult> FromTryGet<T, TResult>(T value, TryGet<T, TResult> tryGet)
Parameters
valueTThe input to give to
tryGet.tryGetTryGet<T, TResult>The method to run.
Returns
- Maybe<TResult>
A Maybe<T> containing the output of
tryGetif it returned true, and one containing no value otherwise.
Type Parameters
TThe type of the input.
TResultThe type of the value the method produces.
Remarks
A caller must write the two type arguments. A method group carries no type
of its own for type inference to work from:
Maybe.FromTryGet<string, int>(s, int.TryParse).
FromTryGet<T1, T2, TResult>(T1, T2, TryGet<T1, T2, TResult>)
Runs a method of the bool Try...(T1, T2, out TResult) shape against
the given inputs and returns what it produced.
[Pure]
public static Maybe<TResult> FromTryGet<T1, T2, TResult>(T1 value1, T2 value2, TryGet<T1, T2, TResult> tryGet)
Parameters
value1T1The first input to give to
tryGet.value2T2The second input to give to
tryGet.tryGetTryGet<T1, T2, TResult>The method to run.
Returns
- Maybe<TResult>
A Maybe<T> containing the output of
tryGetif it returned true, and one containing no value otherwise.
Type Parameters
T1The type of the first input.
T2The type of the second input.
TResultThe type of the value the method produces.
FromTryGet<T1, T2, T3, TResult>(T1, T2, T3, TryGet<T1, T2, T3, TResult>)
Runs a method of the bool Try...(T1, T2, T3, out TResult) shape
against the given inputs and returns what it produced.
[Pure]
public static Maybe<TResult> FromTryGet<T1, T2, T3, TResult>(T1 value1, T2 value2, T3 value3, TryGet<T1, T2, T3, TResult> tryGet)
Parameters
value1T1The first input to give to
tryGet.value2T2The second input to give to
tryGet.value3T3The third input to give to
tryGet.tryGetTryGet<T1, T2, T3, TResult>The method to run.
Returns
- Maybe<TResult>
A Maybe<T> containing the output of
tryGetif it returned true, and one containing no value otherwise.
Type Parameters
T1The type of the first input.
T2The type of the second input.
T3The type of the third input.
TResultThe type of the value the method produces.