• API Reference

    Show / Hide Table of Contents
    • Recore
      • AbsoluteUri
      • AsyncAction
      • AsyncAction<T>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7, T8>
      • AsyncAction<T1, T2, T3, T4, T5, T6, T7>
      • AsyncAction<T1, T2, T3, T4, T5, T6>
      • AsyncAction<T1, T2, T3, T4, T5>
      • AsyncAction<T1, T2, T3, T4>
      • AsyncAction<T1, T2, T3>
      • AsyncAction<T1, T2>
      • AsyncDefer
      • AsyncFunc<T, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, T7, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, T6, TResult>
      • AsyncFunc<T1, T2, T3, T4, T5, TResult>
      • AsyncFunc<T1, T2, T3, T4, TResult>
      • AsyncFunc<T1, T2, T3, TResult>
      • AsyncFunc<T1, T2, TResult>
      • AsyncFunc<TResult>
      • Defer
      • Either
      • Either<TLeft, TRight>
      • Func
      • ObjectExtensions
      • Of<T>
      • OfJsonAttribute
      • Optional
      • Optional<T>
      • RelativeUri
      • Result
      • Result.AsyncCatcher<TValue>
      • Result.Catcher<TValue>
      • Result<TValue, TError>
      • Unit
      • UriExtensions
    • Recore.Collections.Generic
      • AnonymousEqualityComparer<T>
      • ICollectionExtensions
      • IDictionaryExtensions
      • IIterator<T>
      • Iterator
      • LinkedListExtensions
      • ListExtensions
      • MappedComparer<T, TMapped>
      • MappedEqualityComparer<T, TMapped>
    • Recore.Linq
      • Renumerable
    • Recore.Security.Cryptography
      • SecureCompare
    • Recore.Text.Json.Serialization.Converters
      • OverrideEitherConverter<TLeft, TRight>
      • OverrideResultConverter<TValue, TError>
    • Recore.Threading.Tasks
      • TaskExtensions

    Class Optional

    Provides additional methods for Optional<T>.

    Inheritance
    Object
    Optional
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Recore
    Assembly: Recore.dll
    Syntax
    public static class Optional

    Methods

    | Improve this Doc View Source

    AwaitAsync<T>(Optional<Task<T>>)

    Converts an Optional<Task<T>> to a Task<Optional<T>>.

    Declaration
    public static Task<Optional<T>> AwaitAsync<T>(this Optional<Task<T>> optionalTask)
    Parameters
    Type Name Description
    Optional<Task<T>> optionalTask
    Returns
    Type Description
    Task<Optional<T>>
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Flatten<T>(Optional<Optional<T>>)

    Converts an Optional<Optional<T>> to an Optional<T>.

    Declaration
    public static Optional<T> Flatten<T>(this Optional<Optional<T>> optionalOptional)
    Parameters
    Type Name Description
    Optional<Optional<T>> optionalOptional
    Returns
    Type Description
    Optional<T>
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Flatten<T>(Optional<Nullable<T>>)

    Converts an Optional<Nullable<T>> to an Optional<T>.

    Declaration
    public static Optional<T> Flatten<T>(this Optional<T?> optionalNullable)
        where T : struct
    Parameters
    Type Name Description
    Optional<Nullable<T>> optionalNullable
    Returns
    Type Description
    Optional<T>
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    If<T>(Boolean, T)

    Sets an optional value if a condition is true.

    Declaration
    public static Optional<T> If<T>(bool condition, T value)
    Parameters
    Type Name Description
    Boolean condition
    T value
    Returns
    Type Description
    Optional<T>
    Type Parameters
    Name Description
    T
    Remarks

    This method is useful for converting the TryParse pattern to an Optional<T> result.

    | Improve this Doc View Source

    If<T>(Boolean, Func<T>)

    Sets an optional value if a condition is true.

    Declaration
    public static Optional<T> If<T>(bool condition, Func<T> func)
    Parameters
    Type Name Description
    Boolean condition
    Func<T> func
    Returns
    Type Description
    Optional<T>
    Type Parameters
    Name Description
    T
    Remarks

    This method is useful for converting the TryParse pattern to an Optional<T> result.

    | Improve this Doc View Source

    Lift<T>(Action<T>)

    Converts a unary action to work with Optional<T>.

    Declaration
    public static Action<Optional<T>> Lift<T>(Action<T> action)
    Parameters
    Type Name Description
    Action<T> action
    Returns
    Type Description
    Action<Optional<T>>
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Lift<T, TResult>(Func<T, TResult>)

    Converts a unary function to work with Optional<T>.

    Declaration
    public static Func<Optional<T>, Optional<TResult>> Lift<T, TResult>(Func<T, TResult> func)
    Parameters
    Type Name Description
    Func<T, TResult> func
    Returns
    Type Description
    Func<Optional<T>, Optional<TResult>>
    Type Parameters
    Name Description
    T
    TResult
    | Improve this Doc View Source

    NonEmpty<T>(IEnumerable<Optional<T>>)

    Collects the non-empty values from the sequence.

    Declaration
    public static IEnumerable<T> NonEmpty<T>(this IEnumerable<Optional<T>> source)
    Parameters
    Type Name Description
    IEnumerable<Optional<T>> source
    Returns
    Type Description
    IEnumerable<T>
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Of<T>(T)

    Makes a value optional.

    Declaration
    public static Optional<T> Of<T>(T value)
    Parameters
    Type Name Description
    T value
    Returns
    Type Description
    Optional<T>
    Type Parameters
    Name Description
    T
    Remarks

    This is useful for type inference in cases where the implicit conversion can't be used, such as creating an Optional<T> and immediately invoking a method. It can also be passed as a delegate whereas the constructor can't be.

    | Improve this Doc View Source

    Of<T>(Nullable<T>)

    Converts a Nullable<T> to Optional<T>.

    Declaration
    public static Optional<T> Of<T>(T? value)
        where T : struct
    Parameters
    Type Name Description
    Nullable<T> value
    Returns
    Type Description
    Optional<T>
    Type Parameters
    Name Description
    T
    Remarks

    This is a special overload for nullable types to avoid ending up with Optional<T?>. For a value type such as Int32, this method is equivalent to new Optional<int?>(x).Collapse().

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX