Exemplo n.º 1
0
 /// <summary>
 /// The case.
 /// </summary>
 /// <param name="sc">
 /// The sc.
 /// </param>
 /// <param name="predict">
 /// The predict.
 /// </param>
 /// <param name="other">
 /// The other.
 /// </param>
 /// <typeparam name="TCase">
 /// </typeparam>
 /// <typeparam name="TOther">
 /// </typeparam>
 /// <returns>
 /// The <see cref="SwithCase"/>.
 /// </returns>
 public static SwithCase <TCase, TOther> Case <TCase, TOther>(
     this SwithCase <TCase, TOther> sc,
     Predicate <TCase> predict,
     TOther other) where TCase : IEquatable <TCase>
 {
     return(Case(sc, predict, other, true));
 }
Exemplo n.º 2
0
 /// <summary>
 /// The case.
 /// </summary>
 /// <param name="sc">
 /// The sc.
 /// </param>
 /// <param name="option">
 /// The option.
 /// </param>
 /// <param name="other">
 /// The other.
 /// </param>
 /// <typeparam name="TCase">
 /// </typeparam>
 /// <typeparam name="TOther">
 /// </typeparam>
 /// <returns>
 /// The <see cref="SwithCase"/>.
 /// </returns>
 public static SwithCase <TCase, TOther> Case <TCase, TOther>(
     this SwithCase <TCase, TOther> sc,
     TCase option,
     TOther other) where TCase : IEquatable <TCase>
 {
     return(Case(sc, option, other, true));
 }
Exemplo n.º 3
0
 public static void Default <T>(this SwithCase <T> sc, Action <T> action)
 {
     if (sc == null)
     {
         return;
     }
     action(sc.Value);
 }
Exemplo n.º 4
0
 public static void Default <TCase, TOther>(this SwithCase <TCase, TOther> sc, TOther other)
 {
     if (sc == null)
     {
         return;
     }
     sc.Action(other);
 }
Exemplo n.º 5
0
 /// <summary>
 /// The case.
 /// </summary>
 /// <param name="sc">
 /// The sc.
 /// </param>
 /// <param name="option">
 /// The option.
 /// </param>
 /// <param name="other">
 /// The other.
 /// </param>
 /// <param name="bBreak">
 /// The b break.
 /// </param>
 /// <typeparam name="TCase">
 /// </typeparam>
 /// <typeparam name="TOther">
 /// </typeparam>
 /// <returns>
 /// The <see cref="SwithCase"/>.
 /// </returns>
 public static SwithCase <TCase, TOther> Case <TCase, TOther>(
     this SwithCase <TCase, TOther> sc,
     TCase option,
     TOther other,
     bool bBreak) where TCase : IEquatable <TCase>
 {
     return(Case(sc, c => c.Equals(option), other, bBreak));
 }
Exemplo n.º 6
0
 public static SwithCase <TCase, TOther> Case <TCase, TOther>(this SwithCase <TCase, TOther> sc, Predicate <TCase> predict, TOther other, bool bBreak) where TCase : IEquatable <TCase>
 {
     if (sc == null)
     {
         return(null);
     }
     if (predict(sc.Value))
     {
         sc.Action(other);
         return(bBreak ? null : sc);
     }
     else
     {
         return(sc);
     }
 }
Exemplo n.º 7
0
 public static SwithCase <T> Case <T>(this SwithCase <T> sc, Func <T, bool> func, Action <T> action = null, bool bBreak = true)
 {
     if (sc == null)
     {
         return(null);
     }
     if (action == null)
     {
         return(sc);
     }
     if (func(sc.Value))
     {
         action(sc.Value);
         return(bBreak ? null : sc);
     }
     return(sc);
 }
Exemplo n.º 8
0
 public static SwithCase <T> Case <T>(this SwithCase <T> sc, T option, Action <T> action = null, bool bBreak = true)
 {
     if (sc == null)
     {
         return(null);
     }
     if (action == null)
     {
         return(sc);
     }
     if (sc.Value.Equals(option))
     {
         action(sc.Value);
         return(bBreak ? null : sc);
     }
     return(sc);
 }