Пример #1
0
        static string GetFunctionName(FunctionOperatorType operatorType)
        {
            switch (operatorType)
            {
            case FunctionOperatorType.Concat: return("Concat");

            case FunctionOperatorType.Iif: return("Iif");

            case FunctionOperatorType.IsNull: return("Is null");

            default: return(operatorType.ToString());
            }
        }
Пример #2
0
        static string GetFunctionName(FunctionOperatorType operatorType)
        {
            switch (operatorType)
            {
            case FunctionOperatorType.IsNull:
                return("is null");

            case FunctionOperatorType.StartsWith:
                return("StartsWith");

            case FunctionOperatorType.EndsWith:
                return("EndsWith");

            case FunctionOperatorType.Contains:
                return("Contains");

            default:
                return(operatorType.ToString());
            }
        }
Пример #3
0
 public void CheckFunctionArgumentsCount(FunctionOperatorType functionType, int argumentsCount)
 {
     if ((functionType == FunctionOperatorType.Custom || functionType == FunctionOperatorType.Concat) && argumentsCount > 0) return;
     switch (argumentsCount) {
         case 0:
             switch (functionType) {
                 case FunctionOperatorType.LocalDateTimeDayAfterTomorrow:
                 case FunctionOperatorType.LocalDateTimeLastWeek:
                 case FunctionOperatorType.LocalDateTimeNextMonth:
                 case FunctionOperatorType.LocalDateTimeNextWeek:
                 case FunctionOperatorType.LocalDateTimeNextYear:
                 case FunctionOperatorType.LocalDateTimeNow:
                 case FunctionOperatorType.LocalDateTimeThisMonth:
                 case FunctionOperatorType.LocalDateTimeThisWeek:
                 case FunctionOperatorType.LocalDateTimeThisYear:
                 case FunctionOperatorType.LocalDateTimeToday:
                 case FunctionOperatorType.LocalDateTimeTomorrow:
                 case FunctionOperatorType.LocalDateTimeTwoWeeksAway:
                 case FunctionOperatorType.LocalDateTimeYesterday:
                 case FunctionOperatorType.Now:
                 case FunctionOperatorType.UtcNow:
                 case FunctionOperatorType.Today:
                 case FunctionOperatorType.Rnd:
                     return;
             }
             break;
         case 1:
             switch (functionType) {
                 case FunctionOperatorType.IsNullOrEmpty:
                 case FunctionOperatorType.Trim:
                 case FunctionOperatorType.Upper:
                 case FunctionOperatorType.Lower:
                 case FunctionOperatorType.Len:
                 case FunctionOperatorType.IsOutlookIntervalBeyondThisYear:
                 case FunctionOperatorType.IsOutlookIntervalEarlierThisMonth:
                 case FunctionOperatorType.IsOutlookIntervalEarlierThisWeek:
                 case FunctionOperatorType.IsOutlookIntervalEarlierThisYear:
                 case FunctionOperatorType.IsOutlookIntervalLastWeek:
                 case FunctionOperatorType.IsOutlookIntervalLaterThisMonth:
                 case FunctionOperatorType.IsOutlookIntervalLaterThisWeek:
                 case FunctionOperatorType.IsOutlookIntervalLaterThisYear:
                 case FunctionOperatorType.IsOutlookIntervalNextWeek:
                 case FunctionOperatorType.IsOutlookIntervalPriorThisYear:
                 case FunctionOperatorType.IsOutlookIntervalToday:
                 case FunctionOperatorType.IsOutlookIntervalTomorrow:
                 case FunctionOperatorType.IsOutlookIntervalYesterday:
                 case FunctionOperatorType.Ascii:
                 case FunctionOperatorType.Char:
                 case FunctionOperatorType.ToStr:
                 case FunctionOperatorType.Reverse:
                 case FunctionOperatorType.Abs:
                 case FunctionOperatorType.Sqr:
                 case FunctionOperatorType.Cos:
                 case FunctionOperatorType.Sin:
                 case FunctionOperatorType.Atn:
                 case FunctionOperatorType.Exp:
                 case FunctionOperatorType.Log:
                 case FunctionOperatorType.Log10:
                 case FunctionOperatorType.Tan:
                 case FunctionOperatorType.Sign:
                 case FunctionOperatorType.Round:
                 case FunctionOperatorType.Ceiling:
                 case FunctionOperatorType.Floor:
                 case FunctionOperatorType.Asin:
                 case FunctionOperatorType.Acos:
                 case FunctionOperatorType.Cosh:
                 case FunctionOperatorType.Sinh:
                 case FunctionOperatorType.Tanh:
                 case FunctionOperatorType.GetDate:
                 case FunctionOperatorType.GetDay:
                 case FunctionOperatorType.GetDayOfWeek:
                 case FunctionOperatorType.GetDayOfYear:
                 case FunctionOperatorType.GetHour:
                 case FunctionOperatorType.GetMilliSecond:
                 case FunctionOperatorType.GetMinute:
                 case FunctionOperatorType.GetMonth:
                 case FunctionOperatorType.GetSecond:
                 case FunctionOperatorType.GetTimeOfDay:
                 case FunctionOperatorType.GetYear:
                     return;
             }
             break;
         case 2:
             switch (functionType) {
                 case FunctionOperatorType.Substring:
                 case FunctionOperatorType.Log:
                 case FunctionOperatorType.Power:
                 case FunctionOperatorType.Atn2:
                 case FunctionOperatorType.BigMul:
                 case FunctionOperatorType.PadLeft:
                 case FunctionOperatorType.PadRight:
                 case FunctionOperatorType.AddDays:
                 case FunctionOperatorType.AddHours:
                 case FunctionOperatorType.AddMilliSeconds:
                 case FunctionOperatorType.AddMinutes:
                 case FunctionOperatorType.AddMonths:
                 case FunctionOperatorType.AddSeconds:
                 case FunctionOperatorType.AddTicks:
                 case FunctionOperatorType.AddTimeSpan:
                 case FunctionOperatorType.AddYears:
                 case FunctionOperatorType.CharIndex:
                     return;
             }
             break;
         case 3:
             switch (functionType) {
                 case FunctionOperatorType.Substring:
                 case FunctionOperatorType.Iif:
                 case FunctionOperatorType.PadLeft:
                 case FunctionOperatorType.PadRight:
                 case FunctionOperatorType.CharIndex:
                 case FunctionOperatorType.Insert:
                 case FunctionOperatorType.Remove:
                 case FunctionOperatorType.Replace:
                     return;
             }
             break;
         case 4:
             if (functionType == FunctionOperatorType.CharIndex) return;
             break;
     }
     YYError("Wrong arguments count ({0}). Function - '{1}'.", argumentsCount, functionType.ToString());
 }
Пример #4
0
 void TestParseFunction(FunctionOperatorType type, int minArgs, int maxArgs, bool checkWrongArgs)
 {
     List<CriteriaOperator> operands = new List<CriteriaOperator>();
     string criteria = type.ToString() + "( {0} )";
     string args = string.Empty;
     for (int i = 0; i <= (maxArgs + 1); i++) {
         if (i >= minArgs - 1) {
             if (i < minArgs || i > maxArgs) {
                 if(checkWrongArgs)TestParseFunctionWrongArgs(string.Format(criteria, args));
             } else {
                 TestParseFunctionArgs(string.Format(criteria, args), type, operands.ToArray());
             }
         }
         if (!string.IsNullOrEmpty(args)) args = args + ", ";
         args = args + i.ToString();
         operands.Add(new OperandValue(i));
     }
 }