Optional
Various extension and factory methods for constructing optional value.
Returns the second value if the first is empty.
public static Task<Optional<TOutput>> Convert<TInput, TOutput>(this Task<Optional<TInput>> task, Converter<TInput, TOutput> converter)
If a value is present, apply the provided mapping function to it, and if the result is
non-null, return an Optional describing the result. Otherwise returns None.
Converts the monad to Optional<T>.
Flattens the nested optional value.
public static T& modreq(System.Runtime.InteropServices.InAttribute) GetReference<T, TException>(ref Optional optional) where T : struct where TException : Exception
Obtains immutable reference to the value in the container.
public static T& modreq(System.Runtime.InteropServices.InAttribute) GetReference<T>(ref Optional optional, Func<Exception> exceptionFactory) where T : struct
Obtains immutable reference to the value in the container.
public static T& modreq(System.Runtime.InteropServices.InAttribute) GetReference<T>(ref Optional optional, method exceptionFactory) where T : struct
public static T& modreq(System.Runtime.InteropServices.InAttribute) GetReference<T>(ref Optional optional) where T : struct
Obtains immutable reference to the value in the container.
Returns the underlying type argument of the specified optional type.
If a value is present, and the value matches the given predicate,
return an Optional describing the value, otherwise return an empty Optional.
Indicates that specified type is optional type.
Returns empty value.
Wraps null value to Optional<T> container.
Returns the value if present; otherwise return default value.
If a value is present, returns the value, otherwise return default value.
Returns the value if present; otherwise invoke delegate.
If a value is present, returns the value, otherwise null.
If a value is present, returns the value, otherwise null.
public static Task<T> OrThrow<T, TException>(this Task<Optional<T>> task) where TException : Exception
If a value is present, returns the value, otherwise throw exception.
public static Task<T> OrThrow<T, TException>(this Task<Optional<T>> task, Func<TException> exceptionFactory) where TException : Exception
If a value is present, returns the value, otherwise throw exception.
Wraps the value to Optional<T> container.
Constructs optional value from nullable reference type.