Table of Contents

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

tryGet TryGet<TResult>

The method to run.

Returns

Maybe<TResult>

A Maybe<T> containing the output of tryGet if it returned true, and one containing no value otherwise.

Type Parameters

TResult

The 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

value T

The input to give to tryGet.

tryGet TryGet<T, TResult>

The method to run.

Returns

Maybe<TResult>

A Maybe<T> containing the output of tryGet if it returned true, and one containing no value otherwise.

Type Parameters

T

The type of the input.

TResult

The 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

value1 T1

The first input to give to tryGet.

value2 T2

The second input to give to tryGet.

tryGet TryGet<T1, T2, TResult>

The method to run.

Returns

Maybe<TResult>

A Maybe<T> containing the output of tryGet if it returned true, and one containing no value otherwise.

Type Parameters

T1

The type of the first input.

T2

The type of the second input.

TResult

The 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

value1 T1

The first input to give to tryGet.

value2 T2

The second input to give to tryGet.

value3 T3

The third input to give to tryGet.

tryGet TryGet<T1, T2, T3, TResult>

The method to run.

Returns

Maybe<TResult>

A Maybe<T> containing the output of tryGet if it returned true, and one containing no value otherwise.

Type Parameters

T1

The type of the first input.

T2

The type of the second input.

T3

The type of the third input.

TResult

The type of the value the method produces.