Example #1
0
        public static ValueOption <TResult> With <T, TResult>(
            this ValueOption <T> option,
            [NotNull, InstantHandle] Func <T, TResult> selectFunc)
        {
            Code.NotNull(selectFunc, nameof(selectFunc));

            return(option.HasValue ? new ValueOption <TResult>(selectFunc(option.Value)) : None <TResult>());
        }
Example #2
0
        public static ValueOption <TResult> With <T, TResult>(
            this ValueOption <T> option,
            [NotNull, InstantHandle] Func <T, TResult> selectFunc,
            [NotNull, InstantHandle] Func <TResult> defaultFunc)
        {
            Code.NotNull(selectFunc, nameof(selectFunc));
            Code.NotNull(defaultFunc, nameof(defaultFunc));

            return(new ValueOption <TResult>(option.HasValue ? selectFunc(option.Value) : defaultFunc()));
        }
Example #3
0
 /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
 /// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns>
 /// <param name="other">An object to compare with this object.</param>
 public bool Equals(ValueOption <T> other) =>
 !HasValue && !other.HasValue ||
 HasValue && other.HasValue && EqualityComparer <T> .Default.Equals(_value, other._value);