/// <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)); }
/// <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)); }
public static void Default <T>(this SwithCase <T> sc, Action <T> action) { if (sc == null) { return; } action(sc.Value); }
public static void Default <TCase, TOther>(this SwithCase <TCase, TOther> sc, TOther other) { if (sc == null) { return; } sc.Action(other); }
/// <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)); }
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); } }
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); }
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); }