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.Unwrap(
                x => selector(x).Unwrap(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.Unwrap(value => new List <T> {
         value
     }, new List <T>()));
 }
Ejemplo n.º 3
0
 public static T Unwrap <T>(this Maybe <T> maybe, T defaultValue = default(T))
 {
     return(maybe.Unwrap(x => x, defaultValue));
 }
Ejemplo n.º 4
0
 public static T Unwrap <T>(this Maybe <T> maybe, T defaultValue = null)
     where T : class
 {
     return(maybe.Unwrap(x => x, defaultValue));
 }