Ejemplo n.º 1
0
 public DotMethodFPParam(String description, DotMethodFPParamTypeEnum type, Type specificType)
 {
     Description    = description;
     ParamType      = type;
     SpecificType   = specificType;
     LambdaParamNum = 0;
 }
Ejemplo n.º 2
0
 public DotMethodFPParam(int lambdaParamNum, String description, DotMethodFPParamTypeEnum type)
 {
     LambdaParamNum = lambdaParamNum;
     Description    = description;
     ParamType      = type;
     SpecificType   = null;
     if (type == DotMethodFPParamTypeEnum.SPECIFIC)
     {
         throw new ArgumentException("Invalid ctor for specific-type parameter");
     }
 }
Ejemplo n.º 3
0
        public static void ValidateSpecificType(String methodUsedName, DotMethodTypeEnum type, DotMethodFPParamTypeEnum expectedTypeEnum, Type expectedTypeClass, Type providedType, int parameterNum, ExprNode parameterExpression)
        {
            string message = string.Format("Error validating {0} method '{1}', ", type.GetTypeName(), methodUsedName);

            if (expectedTypeEnum == DotMethodFPParamTypeEnum.BOOLEAN && (!providedType.IsBoolean()))
            {
                throw new ExprValidationException(
                          string.Format("{0}expected a boolean-type result for expression parameter {1} but received {2}",
                                        message, parameterNum, providedType.FullName));
            }
            if (expectedTypeEnum == DotMethodFPParamTypeEnum.NUMERIC && (!providedType.IsNumeric()))
            {
                throw new ExprValidationException(
                          string.Format("{0}expected a number-type result for expression parameter {1} but received {2}",
                                        message, parameterNum, providedType.FullName));
            }
            if (expectedTypeEnum == DotMethodFPParamTypeEnum.SPECIFIC)
            {
                var boxedExpectedType = expectedTypeClass.GetBoxedType();
                var boxedProvidedType = providedType.GetBoxedType();
                if (!TypeHelper.IsSubclassOrImplementsInterface(boxedProvidedType, boxedExpectedType))
                {
                    throw new ExprValidationException(
                              string.Format("{0}expected a {1}-type result for expression parameter {2} but received {3}",
                                            message, boxedExpectedType.Name, parameterNum, providedType.FullName));
                }
            }
            else if (expectedTypeEnum == DotMethodFPParamTypeEnum.TIME_PERIOD_OR_SEC)
            {
                if (parameterExpression is ExprTimePeriod || parameterExpression is ExprStreamUnderlyingNode)
                {
                    return;
                }
                if (!providedType.IsNumeric())
                {
                    throw new ExprValidationException(message +
                                                      "expected a time-period expression or a numeric-type result for expression parameter " +
                                                      parameterNum + " but received " +
                                                      TypeHelper.GetTypeNameFullyQualPretty(providedType));
                }
            }
            else if (expectedTypeEnum == DotMethodFPParamTypeEnum.DATETIME)
            {
                if (!providedType.IsDateTime())
                {
                    throw new ExprValidationException(message +
                                                      "expected a long-typed or DateTime-typed result for expression parameter " +
                                                      parameterNum + " but received " +
                                                      TypeHelper.GetTypeNameFullyQualPretty(providedType));
                }
            }
        }