Exemple #1
0
        /// <summary>
        /// Builds an array of signatures for date time functions.
        /// </summary>
        /// <param name="propertyName">The name of the property on DateTime to access.</param>
        /// <returns>The array of signatures for a date time functions.</returns>
        private static BuiltInFunctionSignature[] CreateDateTimeFunctionSignatureArray(string propertyName)
        {
            BuiltInFunctionSignature signatureNonNullable = BuiltInFunctionSignature.CreateFromPropertyAccess(
                propertyName,
                PrimitiveTypeUtils.Int32ResourceType,
                PrimitiveTypeUtils.DateTimeResourceType);

            BuiltInFunctionSignature signatureNullable = BuiltInFunctionSignature.CreateFromPropertyAccess(
                propertyName,
                PrimitiveTypeUtils.Int32ResourceType,
                PrimitiveTypeUtils.NullableDateTimeResourceType);

            return(new BuiltInFunctionSignature[] { signatureNonNullable, signatureNullable });
        }
Exemple #2
0
        /// <summary>
        /// Creates all string functions.
        /// </summary>
        private static void CreateStringFunctions()
        {
            BuiltInFunctionSignature signature;

            BuiltInFunctionSignature[] signatures;

            // bool endswith(string, string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "EndsWith",
                PrimitiveTypeUtils.BoolResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("endswith", new BuiltInFunctionSignature[] { signature });

            // int indexof(string, string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "IndexOf",
                PrimitiveTypeUtils.Int32ResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("indexof", new BuiltInFunctionSignature[] { signature });

            // string replace(string, string, string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "Replace",
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("replace", new BuiltInFunctionSignature[] { signature });

            // bool startswith(string, string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "StartsWith",
                PrimitiveTypeUtils.BoolResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("startswith", new BuiltInFunctionSignature[] { signature });

            // string tolower(string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "ToLower",
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("tolower", new BuiltInFunctionSignature[] { signature });

            // string toupper(string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "ToUpper",
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("toupper", new BuiltInFunctionSignature[] { signature });

            // string trim(string)
            signature = BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                "Trim",
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("trim", new BuiltInFunctionSignature[] { signature });

            signatures = new BuiltInFunctionSignature[]
            {
                // string substring(string, int)
                BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                    "Substring",
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.Int32ResourceType),

                // string substring(string, int?)
                BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                    "Substring",
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.NullableInt32ResourceType),

                // string substring(string, int, int)
                BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                    "Substring",
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.Int32ResourceType,
                    PrimitiveTypeUtils.Int32ResourceType),

                // string substring(string, int?, int)
                BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                    "Substring",
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.NullableInt32ResourceType,
                    PrimitiveTypeUtils.Int32ResourceType),

                // string substring(string, int, int?)
                BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                    "Substring",
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.Int32ResourceType,
                    PrimitiveTypeUtils.NullableInt32ResourceType),

                // string substring(string, int?, int?)
                BuiltInFunctionSignature.CreateFromInstanceMethodCall(
                    "Substring",
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.StringResourceType,
                    PrimitiveTypeUtils.NullableInt32ResourceType,
                    PrimitiveTypeUtils.NullableInt32ResourceType)
            };
            builtInFunctions.Add("substring", signatures);

            // bool substringof(string, string)
            signature = new BuiltInFunctionSignature(
                BuildSubstringOfExpression,
                PrimitiveTypeUtils.BoolResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("substringof", new BuiltInFunctionSignature[] { signature });

            // string concat(string, string)
            signature = BuiltInFunctionSignature.CreateFromStaticMethodCall(
                typeof(string),
                "Concat",
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("concat", new BuiltInFunctionSignature[] { signature });

            // int length(string)
            signature = BuiltInFunctionSignature.CreateFromPropertyAccess(
                "Length",
                PrimitiveTypeUtils.Int32ResourceType,
                PrimitiveTypeUtils.StringResourceType);
            builtInFunctions.Add("length", new BuiltInFunctionSignature[] { signature });
        }