Beispiel #1
0
 public DotMethodFPParam(String description, EPLExpressionParamType type, params Type[] specificType)
 {
     Description    = description;
     ParamType      = type;
     SpecificType   = specificType;
     LambdaParamNum = 0;
 }
Beispiel #2
0
 public static Type GetMethodParamType(this EPLExpressionParamType value)
 {
     if (value == EPLExpressionParamType.BOOLEAN)
     {
         return(typeof(bool?));
     }
     return(typeof(object));
 }
Beispiel #3
0
 public DotMethodFPParam(int lambdaParamNum, String description, EPLExpressionParamType type)
 {
     LambdaParamNum = lambdaParamNum;
     Description    = description;
     ParamType      = type;
     SpecificType   = null;
     if (type == EPLExpressionParamType.SPECIFIC)
     {
         throw new ArgumentException("Invalid ctor for specific-type parameter");
     }
 }
Beispiel #4
0
 public static void ValidateParametersTypePredefined(
     ExprNode[] expressions,
     string invocableName,
     string invocableCategory,
     EPLExpressionParamType type)
 {
     for (var i = 0; i < expressions.Length; i++) {
         ValidateParameterType(
             invocableName,
             invocableCategory,
             true,
             type,
             null,
             expressions[i].Forge.EvaluationType,
             i,
             expressions[i]);
     }
 }
Beispiel #5
0
 public static void ValidateParameterType(
     string invocableName,
     string invocableCategory,
     bool isFunction,
     EPLExpressionParamType expectedTypeEnum,
     Type[] expectedTypeClasses,
     Type providedType,
     int parameterNum,
     ExprNode parameterExpression)
 {
     if (expectedTypeEnum == EPLExpressionParamType.BOOLEAN && (!providedType.IsBoolean()))
     {
         throw new ExprValidationException(GetInvokablePrefix(invocableName, invocableCategory, isFunction) + "expected a bool-type result for expression parameter " + parameterNum + " but received " + providedType.GetCleanName());
     }
     if (expectedTypeEnum == EPLExpressionParamType.NUMERIC && (!providedType.IsNumeric()))
     {
         throw new ExprValidationException(GetInvokablePrefix(invocableName, invocableCategory, isFunction) + "expected a number-type result for expression parameter " + parameterNum + " but received " + providedType.GetCleanName());
     }
     if (expectedTypeEnum == EPLExpressionParamType.SPECIFIC)
     {
         var boxedProvidedType = providedType.GetBoxedType();
         var found             = false;
         foreach (var expectedTypeClass in expectedTypeClasses)
         {
             var boxedExpectedType = expectedTypeClass.GetBoxedType();
             if (boxedProvidedType != null && TypeHelper.IsSubclassOrImplementsInterface(boxedProvidedType, boxedExpectedType))
             {
                 found = true;
                 break;
             }
         }
         if (!found)
         {
             string expected;
             if (expectedTypeClasses.Length == 1)
             {
                 expected = "a " + TypeHelper.GetParameterAsString(expectedTypeClasses);
             }
             else
             {
                 expected = "any of [" + TypeHelper.GetParameterAsString(expectedTypeClasses) + "]";
             }
             throw new ExprValidationException(GetInvokablePrefix(invocableName, invocableCategory, isFunction) + "expected " + expected + "-type result for expression parameter " + parameterNum + " but received " + providedType.GetCleanName());
         }
     }
     if (expectedTypeEnum == EPLExpressionParamType.TIME_PERIOD_OR_SEC)
     {
         if (parameterExpression is ExprTimePeriod || parameterExpression is ExprStreamUnderlyingNode)
         {
             return;
         }
         if (!(TypeHelper.IsNumeric(providedType)))
         {
             throw new ExprValidationException(GetInvokablePrefix(invocableName, invocableCategory, isFunction) + "expected a time-period expression or a numeric-type result for expression parameter " + parameterNum + " but received " + providedType.GetCleanName());
         }
     }
     if (expectedTypeEnum == EPLExpressionParamType.DATETIME)
     {
         if (!TypeHelper.IsDateTime(providedType))
         {
             throw new ExprValidationException(GetInvokablePrefix(invocableName, invocableCategory, isFunction) + "expected a long-typed, Date-typed or Calendar-typed result for expression parameter " + parameterNum + " but received " + providedType.GetCleanName());
         }
     }
 }
Beispiel #6
0
 public static void ValidateParametersTypePredefined(
     IList <ExprNode> expressions, string invocableName, string invocableCategory, EPLExpressionParamType type)
 {
     for (int i = 0; i < expressions.Count; i++)
     {
         EPLValidationUtil.ValidateParameterType(
             invocableName,
             invocableCategory, true, type, null,
             expressions[i].ExprEvaluator.ReturnType,
             i, expressions[i]);
     }
 }
Beispiel #7
0
 public DotMethodFPParam(
     string description,
     EPLExpressionParamType paramType)
     : this(description, paramType, null)
 {
 }