Ejemplo n.º 1
0
 public static Maybe <V> SelectMany <T, U, V>(this Maybe <T> maybe,
                                              Func <T, Maybe <U> > selector,
                                              Func <T, U, V> project)
 {
     return(maybe.GetValueOrDefault(
                x => selector(x).GetValueOrDefault(u => project(x, u), Maybe <V> .None),
                Maybe <V> .None));
 }
Ejemplo n.º 2
0
 public static List <T> ToList <T>(this Maybe <T> maybe)
 {
     return(maybe.GetValueOrDefault(value => new List <T> {
         value
     }, new List <T>()));
 }
Ejemplo n.º 3
0
 public static K Unwrap <T, K>(this Maybe <T> maybe, Func <T, K> selector, K defaultValue = default(K))
 {
     return(maybe.GetValueOrDefault(selector, defaultValue));
 }
Ejemplo n.º 4
0
 public static T Unwrap <T>(this Maybe <T> maybe, T defaultValue = default)
 {
     return(maybe.GetValueOrDefault(defaultValue));
 }
Ejemplo n.º 5
0
 public static void Deconstruct <T>(this Maybe <T> result, out bool hasValue, out T value)
 {
     hasValue = result.HasValue;
     value    = result.GetValueOrDefault();
 }