Exemple #1
0
        private static void RegisterOwnFunctions()
        {
            RegisteredObjects.AddFunctionCategory("MyFuncs", "My Functions");

            // obtain MethodInfo for our functions
            Type       myType            = typeof(MyFunctions);
            MethodInfo myUpperCaseFunc   = myType.GetMethod("MyUpperCase");
            MethodInfo myMaximumIntFunc  = myType.GetMethod("MyMaximum", new Type[] { typeof(int), typeof(int) });
            MethodInfo myMaximumLongFunc = myType.GetMethod("MyMaximum", new Type[] { typeof(long), typeof(long) });

            // register simple function
            RegisteredObjects.AddFunction(myUpperCaseFunc, "MyFuncs");

            // register overridden functions
            RegisteredObjects.AddFunction(myMaximumIntFunc, "MyFuncs,MyMaximum");
            RegisteredObjects.AddFunction(myMaximumLongFunc, "MyFuncs,MyMaximum");
        }
Exemple #2
0
        private static void RegisterFunctions()
        {
            //Add Funct
            RegisteredObjects.AddFunctionCategory("Custom", "Custom Functions");
            //Obtain MethodInfo for our functions
            Type       customFuncType    = typeof(CustomFunctions);
            MethodInfo funcRes           = customFuncType.GetMethod("Res", new Type[] { typeof(string) });
            MethodInfo funcGetParam      = customFuncType.GetMethod("GetParam", new Type[] { typeof(string) });
            MethodInfo funcPref          = customFuncType.GetMethod("Pref", new Type[] { typeof(string) });
            MethodInfo funcVar           = customFuncType.GetMethod("Var", new Type[] { typeof(string) });
            MethodInfo funcLog           = customFuncType.GetMethod("Log", new Type[] { typeof(string) });
            MethodInfo funcDebug         = customFuncType.GetMethod("Debug", new Type[] { typeof(object) });
            MethodInfo funcExtendedValue = customFuncType.GetMethod("ExtendedValue", new Type[] { typeof(decimal), typeof(string) });

            //Register simple function
            RegisteredObjects.AddFunction(funcRes, "Custom");
            RegisteredObjects.AddFunction(funcGetParam, "Custom");
            RegisteredObjects.AddFunction(funcPref, "Custom");
            RegisteredObjects.AddFunction(funcVar, "Custom");
            RegisteredObjects.AddFunction(funcLog, "Custom");
            RegisteredObjects.AddFunction(funcDebug, "Custom");
            RegisteredObjects.AddFunction(funcExtendedValue, "Custom");
        }
Exemple #3
0
        internal static void Register()
        {
            #region Math
            RegisteredObjects.AddFunctionCategory("Math", "Functions,Math");
            Type math = typeof(Math);
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(sbyte) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(short) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(int) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(long) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(float) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(double) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Abs", new Type[] { typeof(decimal) }), "Math,Abs");
            RegisteredObjects.AddFunction(math.GetMethod("Acos"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Asin"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Atan"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Ceiling", new Type[] { typeof(double) }), "Math,Ceiling");
            RegisteredObjects.AddFunction(math.GetMethod("Ceiling", new Type[] { typeof(decimal) }), "Math,Ceiling");
            RegisteredObjects.AddFunction(math.GetMethod("Cos"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Exp"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Floor", new Type[] { typeof(double) }), "Math,Floor");
            RegisteredObjects.AddFunction(math.GetMethod("Floor", new Type[] { typeof(decimal) }), "Math,Floor");
            RegisteredObjects.AddFunction(math.GetMethod("Log", new Type[] { typeof(double) }), "Math");
            Type myMath = typeof(StdFunctions);
            RegisteredObjects.AddFunction(myMath.GetMethod("Maximum", new Type[] { typeof(int), typeof(int) }), "Math,Maximum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Maximum", new Type[] { typeof(long), typeof(long) }), "Math,Maximum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Maximum", new Type[] { typeof(float), typeof(float) }), "Math,Maximum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Maximum", new Type[] { typeof(double), typeof(double) }), "Math,Maximum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Maximum", new Type[] { typeof(decimal), typeof(decimal) }), "Math,Maximum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Minimum", new Type[] { typeof(int), typeof(int) }), "Math,Minimum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Minimum", new Type[] { typeof(long), typeof(long) }), "Math,Minimum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Minimum", new Type[] { typeof(float), typeof(float) }), "Math,Minimum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Minimum", new Type[] { typeof(double), typeof(double) }), "Math,Minimum");
            RegisteredObjects.AddFunction(myMath.GetMethod("Minimum", new Type[] { typeof(decimal), typeof(decimal) }), "Math,Minimum");
            RegisteredObjects.AddFunction(math.GetMethod("Round", new Type[] { typeof(double) }), "Math,Round");
            RegisteredObjects.AddFunction(math.GetMethod("Round", new Type[] { typeof(decimal) }), "Math,Round");
            RegisteredObjects.AddFunction(math.GetMethod("Round", new Type[] { typeof(double), typeof(int) }), "Math,Round");
            RegisteredObjects.AddFunction(math.GetMethod("Round", new Type[] { typeof(decimal), typeof(int) }), "Math,Round");
            RegisteredObjects.AddFunction(math.GetMethod("Sin"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Sqrt"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Tan"), "Math");
            RegisteredObjects.AddFunction(math.GetMethod("Truncate", new Type[] { typeof(double) }), "Math,Truncate");
            RegisteredObjects.AddFunction(math.GetMethod("Truncate", new Type[] { typeof(decimal) }), "Math,Truncate");
            #endregion

            #region Text
            RegisteredObjects.AddFunctionCategory("Text", "Functions,Text");
            Type str = typeof(StdFunctions);
            RegisteredObjects.AddFunction(str.GetMethod("Asc"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("Chr"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("Insert"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("Length"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("LowerCase"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("PadLeft", new Type[] { typeof(string), typeof(int) }), "Text,PadLeft");
            RegisteredObjects.AddFunction(str.GetMethod("PadLeft", new Type[] { typeof(string), typeof(int), typeof(char) }), "Text,PadLeft");
            RegisteredObjects.AddFunction(str.GetMethod("PadRight", new Type[] { typeof(string), typeof(int) }), "Text,PadRight");
            RegisteredObjects.AddFunction(str.GetMethod("PadRight", new Type[] { typeof(string), typeof(int), typeof(char) }), "Text,PadRight");
            RegisteredObjects.AddFunction(str.GetMethod("Remove", new Type[] { typeof(string), typeof(int) }), "Text,Remove");
            RegisteredObjects.AddFunction(str.GetMethod("Remove", new Type[] { typeof(string), typeof(int), typeof(int) }), "Text,Remove");
            RegisteredObjects.AddFunction(str.GetMethod("Replace"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("Substring", new Type[] { typeof(string), typeof(int) }), "Text,Substring");
            RegisteredObjects.AddFunction(str.GetMethod("Substring", new Type[] { typeof(string), typeof(int), typeof(int) }), "Text,Substring");
            RegisteredObjects.AddFunction(str.GetMethod("TitleCase"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("Trim"), "Text");
            RegisteredObjects.AddFunction(str.GetMethod("UpperCase"), "Text");
            #endregion

            #region Date & Time
            RegisteredObjects.AddFunctionCategory("DateTime", "Functions,DateTime");
            Type dt = typeof(StdFunctions);
            RegisteredObjects.AddFunction(dt.GetMethod("AddDays"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("AddHours"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("AddMinutes"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("AddMonths"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("AddSeconds"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("AddYears"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("DateDiff"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("DateSerial"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("Day"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("DayOfWeek"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("DayOfYear"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("DaysInMonth"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("Hour"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("Minute"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("Month"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("MonthName"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("Second"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("WeekOfYear"), "DateTime");
            RegisteredObjects.AddFunction(dt.GetMethod("Year"), "DateTime");
            #endregion

            #region Formatting
            RegisteredObjects.AddFunctionCategory("Formatting", "Functions,Formatting");
            Type fmt = typeof(StdFunctions);
            RegisteredObjects.AddFunction(fmt.GetMethod("Format", new Type[] { typeof(string), typeof(object[]) }), "Formatting");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatCurrency", new Type[] { typeof(object) }), "Formatting,FormatCurrency");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatCurrency", new Type[] { typeof(object), typeof(int) }), "Formatting,FormatCurrency");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatDateTime", new Type[] { typeof(DateTime) }), "Formatting,FormatDateTime");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatDateTime", new Type[] { typeof(DateTime), typeof(string) }), "Formatting,FormatDateTime");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatNumber", new Type[] { typeof(object) }), "Formatting,FormatNumber");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatNumber", new Type[] { typeof(object), typeof(int) }), "Formatting,FormatNumber");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatPercent", new Type[] { typeof(object) }), "Formatting,FormatPercent");
            RegisteredObjects.AddFunction(fmt.GetMethod("FormatPercent", new Type[] { typeof(object), typeof(int) }), "Formatting,FormatPercent");
            #endregion

            #region Conversion
            RegisteredObjects.AddFunctionCategory("Conversion", "Functions,Conversion");
            Type stdConv = typeof(Convert);
            Type myConv  = typeof(StdFunctions);
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToBoolean", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToByte", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToChar", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToDateTime", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToDecimal", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToDouble", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToInt32", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToRoman"), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToSingle", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(stdConv.GetMethod("ToString", new Type[] { typeof(object) }), "Conversion");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWords", new Type[] { typeof(object) }), "Conversion,ToWords");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWords", new Type[] { typeof(object), typeof(string) }), "Conversion,ToWords");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWords", new Type[] { typeof(object), typeof(string), typeof(string) }), "Conversion,ToWords");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsEnGb", new Type[] { typeof(object) }), "Conversion,ToWordsEnGb");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsEnGb", new Type[] { typeof(object), typeof(string) }), "Conversion,ToWordsEnGb");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsEnGb", new Type[] { typeof(object), typeof(string), typeof(string) }), "Conversion,ToWordsEnGb");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsEs", new Type[] { typeof(object) }), "Conversion,ToWordsEs");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsEs", new Type[] { typeof(object), typeof(string) }), "Conversion,ToWordsEs");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsEs", new Type[] { typeof(object), typeof(string), typeof(string) }), "Conversion,ToWordsEs");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsRu", new Type[] { typeof(object) }), "Conversion,ToWordsRu");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsRu", new Type[] { typeof(object), typeof(string) }), "Conversion,ToWordsRu");
            RegisteredObjects.AddFunction(myConv.GetMethod("ToWordsRu", new Type[] { typeof(object), typeof(bool), typeof(string), typeof(string), typeof(string) }), "Conversion,ToWordsRu");
            #endregion

            #region Program Flow
            RegisteredObjects.AddFunctionCategory("ProgramFlow", "Functions,ProgramFlow");
            Type misc = typeof(StdFunctions);
            RegisteredObjects.AddFunction(misc.GetMethod("Choose"), "ProgramFlow");
            RegisteredObjects.AddFunction(misc.GetMethod("IIf"), "ProgramFlow");
            RegisteredObjects.AddFunction(misc.GetMethod("Switch"), "ProgramFlow");
            RegisteredObjects.AddFunction(misc.GetMethod("IsNull"), "ProgramFlow");
            #endregion
        }