Ejemplo n.º 1
0
        public static dynamic Break <T>(this SwitchSugarModel <T> switchSugar)
        {
            string reval = switchSugar.ReturnVal;

            switchSugar = null;//清空对象,节约性能
            return(reval);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Switch().Case().Default().Break()
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static SwitchSugarModel <T> Switch <T>(this T thisValue)
        {
            var reval = new SwitchSugarModel <T>();

            reval.SourceValue = thisValue;
            return(reval);
        }
Ejemplo n.º 3
0
 public static SwitchSugarModel <T> Default <T, TReturn>(this SwitchSugarModel <T> switchSugar, TReturn returnValue)
 {
     if (switchSugar.IsEquals == false)
     {
         switchSugar.ReturnVal = returnValue;
     }
     return(switchSugar);
 }
Ejemplo n.º 4
0
 public static SwitchSugarModel <T> Case <T, TReturn>(this SwitchSugarModel <T> switchSugar, T caseValue, TReturn returnValue)
 {
     if (switchSugar.SourceValue.Equals(caseValue))
     {
         switchSugar.IsEquals  = true;
         switchSugar.ReturnVal = returnValue;
     }
     return(switchSugar);
 }