Beispiel #1
0
 public static SwitchResult <TResult, IEnumerable <T> > Switch <T, TResult>(this SwitchResult <TResult, IEnumerable <T> > arg, IEnumerable <T> checkValue, Func <IEnumerable <T>, TResult> func)
 {
     if (!arg.HasValue && (arg.Arg.IsNull() && checkValue.IsNull() || arg.Arg.NotNull() && arg.Arg.SeqEquals(checkValue)))
     {
         return(arg.SetValue(func(arg.Arg)));
     }
     return(arg);
 }
Beispiel #2
0
 public static SwitchResult <TResult, T> Switch <T, TResult>(this SwitchResult <TResult, T> arg, Func <T, bool> check, Func <T, TResult> func)
 {
     if (!arg.HasValue && check(arg.Arg))
     {
         return(arg.SetValue(func(arg.Arg)));
     }
     return(arg);
 }
Beispiel #3
0
 public static SwitchResult <T> Switch <T>(this SwitchResult <T> arg, Func <T, bool> check, Action <T> func)
 {
     if (!arg.HasValue && check(arg.Arg))
     {
         return(arg.Done(func));
     }
     return(arg);
 }
Beispiel #4
0
 public static SwitchResult <TResult, T> Switch <T, TResult>(this SwitchResult <TResult, T> arg, T checkValue, Func <T, TResult> func)
 {
     if (!arg.HasValue && (arg.Arg.IsNull() && checkValue.IsNull() || arg.Arg.NotNull() && arg.Arg.Equals(checkValue)))
     {
         return(arg.SetValue(func(arg.Arg)));
     }
     return(arg);
 }
Beispiel #5
0
        public static SwitchResult <TResult, T> SwitchNotNull <T, TMiddle, TResult>(this SwitchResult <TResult, T> arg, Func <T, TMiddle> getValue, Func <TMiddle, TResult> func)
        {
            if (arg.HasValue)
            {
                return(arg);
            }
            TMiddle value = getValue(arg.Arg);

            if (value.NotNull())
            {
                return(arg.SetValue(func(value)));
            }
            return(arg);
        }