Ejemplo n.º 1
0
 public static MaybeEnumerable <TInput> Do <TInput>(this MaybeEnumerable <TInput> o, Action <TInput> action)
 {
     if (o == null || !o.HasValue)
     {
         return(MaybeEnumerable <TInput> .Empty);
     }
     foreach (var e in o.Where(e => e.HasValue))
     {
         action(e.Value);
     }
     return(o);
 }
Ejemplo n.º 2
0
 public static MaybeEnumerable <TResult> Return <TInput, TResult>(this MaybeEnumerable <TInput> o,
                                                                  Func <TInput, TResult> evaluator, Func <TResult> failureValue) =>
 o == null || !o.HasValue
         ? MaybeEnumerable <TResult> .Empty
         : new MaybeEnumerableApplicator <TInput, TResult>(o, evaluator, failureValue);
Ejemplo n.º 3
0
 public static MaybeEnumerable <TResult> With <TInput, TResult>(this MaybeEnumerable <TInput> o, Func <TInput, TResult> evaluator) =>
 o == null || !o.HasValue
     ? MaybeEnumerable <TResult> .Empty
     : new MaybeEnumerableApplicator <TInput, TResult>(o, evaluator);
Ejemplo n.º 4
0
 public static Maybe <T> Single <T>(this MaybeEnumerable <T> value, Func <T, bool> predicate)
 => SingleImpl(value, predicate);
Ejemplo n.º 5
0
 public static Maybe <T> First <T>(this MaybeEnumerable <T> value, Func <T, bool> predicate)
 => FirstImpl(value, predicate);
Ejemplo n.º 6
0
 public static ListMatcherContext <TV> Match <TV>(this MaybeEnumerable <TV> v)
 {
     return(new ListMatcherContext <TV>(v.Value.Select(x => x.Value).ToMaybeNonEmpty()));
 }
Ejemplo n.º 7
0
 public static MaybeEnumerable <TInput> ApplyUnless <TInput>(this MaybeEnumerable <TInput> o, Func <TInput, bool> evaluator, Func <TInput, TInput> action)
 => o == null || !o.HasValue
     ? MaybeEnumerable <TInput> .Empty
     : new MaybeEnumerableConditionalApplicator <TInput>(o, evaluator, action, true);