Example #1
0
        public static ExprEvaluator ValidateSizeParam(
            string viewName,
            StatementContext statementContext,
            ExprNode sizeNode,
            int expressionNumber)
        {
            var sizeEvaluator = sizeNode.ExprEvaluator;
            var returnType    = sizeEvaluator.ReturnType.GetBoxedType();

            if (!returnType.IsNumeric() ||
                returnType.IsFloatingPointClass() ||
                returnType.IsBoxedType <long>())
            {
                throw new ViewParameterException(GetViewParamMessage(viewName));
            }
            if (sizeNode.IsConstantResult)
            {
                var size = ViewFactorySupport.Evaluate(sizeEvaluator, expressionNumber, viewName, statementContext);
                if (!ValidateSize(size))
                {
                    throw new ViewParameterException(GetSizeValidationMsg(viewName, size));
                }
            }
            return(sizeEvaluator);
        }
Example #2
0
 public static ExprTimePeriodEvalDeltaConstFactory ValidateAndEvaluateTimeDeltaFactory(
     string viewName,
     StatementContext statementContext,
     ExprNode expression,
     string expectedMessage,
     int expressionNumber)
 {
     var streamTypeService = new StreamTypeServiceImpl(statementContext.EngineURI, false);
     ExprTimePeriodEvalDeltaConstFactory factory;
     if (expression is ExprTimePeriod)
     {
         var validated = (ExprTimePeriod) ViewFactorySupport.ValidateExpr(
             viewName, statementContext, expression, streamTypeService, expressionNumber);
         factory = validated.ConstEvaluator(new ExprEvaluatorContextStatement(statementContext, false));
     }
     else
     {
         var validated = ViewFactorySupport.ValidateExpr(
             viewName, statementContext, expression, streamTypeService, expressionNumber);
         var secondsEvaluator = validated.ExprEvaluator;
         var returnType = secondsEvaluator.ReturnType.GetBoxedType();
         if (!returnType.IsNumeric())
         {
             throw new ViewParameterException(expectedMessage);
         }
         if (validated.IsConstantResult)
         {
             var time = ViewFactorySupport.Evaluate(secondsEvaluator, 0, viewName, statementContext);
             if (!ExprTimePeriodUtil.ValidateTime(time, statementContext.TimeAbacus))
             {
                 throw new ViewParameterException(ExprTimePeriodUtil.GetTimeInvalidMsg(viewName, "view", time));
             }
             var msec = statementContext.TimeAbacus.DeltaForSecondsNumber(time);
             factory = new ExprTimePeriodEvalDeltaConstGivenDelta(msec);
         }
         else
         {
             factory = new ExprTimePeriodEvalDeltaConstFactoryMsec(secondsEvaluator, statementContext.TimeAbacus);
         }
     }
     return factory;
 }