/// <summary> /// Builds an array of signatures for math functions. /// </summary> /// <param name="methodName">The name of the method to call on the Math class.</param> /// <returns>The array of signatures for math functions.</returns> private static BuiltInFunctionSignature[] CreateMathFunctionSignatureArray(string methodName) { BuiltInFunctionSignature doubleSignature = BuiltInFunctionSignature.CreateFromStaticMethodCall( typeof(Math), methodName, PrimitiveTypeUtils.DoubleResourceType, PrimitiveTypeUtils.DoubleResourceType); BuiltInFunctionSignature nullableDoubleSignature = BuiltInFunctionSignature.CreateFromStaticMethodCall( typeof(Math), methodName, PrimitiveTypeUtils.DoubleResourceType, PrimitiveTypeUtils.NullableDoubleResourceType); BuiltInFunctionSignature decimalSignature = BuiltInFunctionSignature.CreateFromStaticMethodCall( typeof(Math), methodName, PrimitiveTypeUtils.DecimalResourceType, PrimitiveTypeUtils.DecimalResourceType); BuiltInFunctionSignature nullableDecimalSignature = BuiltInFunctionSignature.CreateFromStaticMethodCall( typeof(Math), methodName, PrimitiveTypeUtils.DecimalResourceType, PrimitiveTypeUtils.NullableDecimalResourceType); return(new BuiltInFunctionSignature[] { doubleSignature, decimalSignature, nullableDoubleSignature, nullableDecimalSignature }); }
/// <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 }); }