Exemplo n.º 1
0
        private static Result doIF(object dat, evalIFType eval)
        {
            condBase cond = eval.cond.Item;

            if (doCond(dat, cond))
            {
                return(doEval(dat, eval.then.Item));
            }
            else
            {
                return(doEval(dat, [email protected]));
            }
        }
Exemplo n.º 2
0
 private static bool doCond(object dat, condBase cond)
 {
     if (cond is condANDType)
     {
         condANDType and = (condANDType)cond;
         foreach (condBase anditem in and.Items)
         {
             if (!doCond(dat, anditem))
             {
                 return(false);
             }
         }
         return(true);
     }
     else if (cond is condORType)
     {
         condORType or = (condORType)cond;
         foreach (condBase oritem in or.Items)
         {
             if (doCond(dat, oritem))
             {
                 return(true);
             }
         }
         return(false);
     }
     else if (cond is condNOTType)
     {
         return(!doCond(dat, ((condNOTType)cond).Item));
     }
     else if (cond is condISNULLType)
     {
         condISNULLType isnull       = (condISNULLType)cond;
         Result         resultisnull = doEval(dat, isnull.Item);
         return(resultisnull.IsNull);
     }
     else if (cond is condEQType)
     {
         condEQType eq = (condEQType)cond;
         string     a  = string.Format("{0}", doEval(dat, eq.Items[0]).Value);
         string     b  = string.Format("{0}", doEval(dat, eq.Items[1]).Value);
         return(string.Equals(a, b, StringComparison.CurrentCultureIgnoreCase));
     }
     else if (cond is condGEType)
     {
         condGEType x = (condGEType)cond;
         return(compareVals(dat, x.Items[0], x.Items[1]) >= 0);
     }
     else if (cond is condGTType)
     {
         condGTType x = (condGTType)cond;
         return(compareVals(dat, x.Items[0], x.Items[1]) > 0);
     }
     else if (cond is condLEType)
     {
         condLEType x = (condLEType)cond;
         return(compareVals(dat, x.Items[0], x.Items[1]) <= 0);
     }
     else if (cond is condLTType)
     {
         condLTType x = (condLTType)cond;
         return(compareVals(dat, x.Items[0], x.Items[1]) < 0);
     }
     else if (cond is condLIKEType)
     {
         condLIKEType x = (condLIKEType)cond;
         return(compareLIKE(dat, x.Items[0], x.Items[1]));
     }
     throw new Exception(string.Format("Ошибка - неизвестный тип {0} в функции doCond", cond.GetType()));
 }