Пример #1
0
        public void CalculateTest(double firstValue, double expected)
        {
            var    calculator   = new Acos();
            double actualResult = calculator.Calculate(-1);

            Assert.AreEqual(3.1416, actualResult, 0.0001);
        }
Пример #2
0
        public void AcosIntAndDoublesAsInputs()
        {
            var function = new Acos();

            var input1 = 20;
            var input2 = 100;
            var input3 = 1;
            var input4 = 1.0;
            var input5 = 1.5;
            var input6 = 1000;

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);
            var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext);
            var result6 = function.Execute(FunctionsHelper.CreateArgs(input6), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result2.Result).Type);
            Assert.AreEqual(0, System.Math.Round(result3.ResultNumeric, 9));
            Assert.AreEqual(0, System.Math.Round(result4.ResultNumeric, 9));
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result5.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result6.Result).Type);
        }
Пример #3
0
        public void AcosHandlesNormal12HourClockInputs()
        {
            var function = new Acos();

            var input1 = "00:00:00 AM";
            var input2 = "00:01:32 AM";
            var input3 = "12:00 PM";
            var input4 = "12:00 AM";
            var input6 = "1:00 PM";
            var input8 = "1:10:32 am";
            var input9 = "3:42:32 pm";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);
            var result6 = function.Execute(FunctionsHelper.CreateArgs(input6), this.ParsingContext);
            var result8 = function.Execute(FunctionsHelper.CreateArgs(input8), this.ParsingContext);
            var result9 = function.Execute(FunctionsHelper.CreateArgs(input9), this.ParsingContext);

            Assert.AreEqual(1.570796327, result1.ResultNumeric, .00001);
            Assert.AreEqual(1.569731512, System.Math.Round(result2.ResultNumeric, 9));
            Assert.AreEqual(1.047197551, result3.ResultNumeric, .00001);
            Assert.AreEqual(1.570796327, result4.ResultNumeric, .00001);
            Assert.AreEqual(0.998377755, System.Math.Round(result6.ResultNumeric, 9));
            Assert.AreEqual(1.521795238, System.Math.Round(result8.ResultNumeric, 9));
            Assert.AreEqual(0.857226229, System.Math.Round(result9.ResultNumeric, 9));
        }
Пример #4
0
        public void AcosTestInputsWithDatesThatHaveSlashesInThem()
        {
            var function = new Acos();

            var input1 = "1/17/2011 2:00 am";
            var input2 = "17/01/2011 2:00 AM";
            var input3 = "17/Jan/2011 2:00 AM";
            var input4 = "17/January/2011 2:00 am";
            var input5 = "1/17/2011 2:00:00 am";
            var input6 = "17/01/2011 2:00:00 AM";
            var input7 = "17/Jan/2011 2:00:00 AM";
            var input8 = "17/January/2011 2:00:00 am";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);
            var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext);
            var result6 = function.Execute(FunctionsHelper.CreateArgs(input6), this.ParsingContext);
            var result7 = function.Execute(FunctionsHelper.CreateArgs(input7), this.ParsingContext);
            var result8 = function.Execute(FunctionsHelper.CreateArgs(input8), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result2.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result3.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result4.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result5.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result6.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result7.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result8.Result).Type);
        }
Пример #5
0
        public void Calculate(double input, double output)
        {
            var calculator = new Acos();
            var testResult = calculator.Calculate(input);
            var result     = output;

            Assert.AreEqual(testResult, result, 0.01);
        }
Пример #6
0
        public void AcosWithInvalidArgumentReturnsPoundValue()
        {
            var func           = new Acos();
            var parsingContext = ParsingContext.Create();
            var args           = FunctionsHelper.CreateArgs();
            var result         = func.Execute(args, parsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Пример #7
0
        public void AcosShouldReturnCorrectResult()
        {
            var func          = new Acos();
            var args          = FunctionsHelper.CreateArgs(0.1);
            var result        = func.Execute(args, _parsingContext);
            var roundedResult = Math.Round((double)result.Result, 4);

            Assert.AreEqual(1.4706, roundedResult);
        }
Пример #8
0
        public void AcosHandlesMilitaryTimesPast2400()
        {
            var function = new Acos();

            var input1 = "01:00";
            var input2 = "02:00";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);

            Assert.AreEqual(1.529117594, System.Math.Round(result1.ResultNumeric, 9));
            Assert.AreEqual(1.48736624, System.Math.Round(result2.ResultNumeric, 9));
        }
Пример #9
0
        public void AcosHandlesTrueOrFalse()
        {
            var function = new Acos();

            var input1 = true;
            var input2 = false;

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);

            Assert.AreEqual(0, System.Math.Round(result1.ResultNumeric, 9));
            Assert.AreEqual(1.570796327, System.Math.Round(result2.ResultNumeric, 9));
        }
Пример #10
0
        public void AcosHandlesInputDatesAreSeperatedByDashes()
        {
            var function = new Acos();

            var input1 = "1-17-2017 2:00";
            var input2 = "1-17-2017 2:00 am";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result2.Result).Type);
        }
Пример #11
0
        public void AcosHandlesMilitaryTime()
        {
            var function = new Acos();

            var input1 = "00:00";
            var input2 = "00:01";
            var input3 = "23:59:59";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);

            Assert.AreEqual(1.570796327, result1.ResultNumeric, .000001);
            Assert.AreEqual(1.570101882, System.Math.Round(result2.ResultNumeric, 9));
            Assert.AreEqual(0.004811257, System.Math.Round(result3.ResultNumeric, 9));
        }
Пример #12
0
        public void AcosIsGivenAStringAsInput()
        {
            var function = new Acos();

            var input1 = "string";
            var input2 = "0";
            var input3 = "1";
            var input4 = "1.5";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(1.570796327, result2.ResultNumeric, .00001);
            Assert.AreEqual(0, result3.ResultNumeric, .00001);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result4.Result).Type);
        }
Пример #13
0
        public void AcosHandlesDateTimeInputs()
        {
            var function = new Acos();

            var input1 = "1/17/2011 2:00";
            var input2 = "1/17/2011 2:00 AM";
            var input3 = "17/1/2011 2:00 AM";
            var input4 = "17/Jan/2011 2:00 AM";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result2.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result3.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result4.Result).Type);
        }
Пример #14
0
        public void AcosTestMilitaryTimeAndNormalTimeComparisions()
        {
            var function = new Acos();

            var input1 = "16:30";
            var input2 = "04:30 pm";
            var input3 = "02:30";
            var input4 = "2:30 am";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);

            Assert.AreEqual(0.812755561, System.Math.Round(result1.ResultNumeric, 9));
            Assert.AreEqual(0.812755561, System.Math.Round(result2.ResultNumeric, 9));
            Assert.AreEqual(1.466440354, System.Math.Round(result3.ResultNumeric, 9));
            Assert.AreEqual(1.466440354, System.Math.Round(result4.ResultNumeric, 9));
        }
Пример #15
0
        public void AcosHandlesInputsWithDatesInTheFormMonthDateCommaYearTime()
        {
            var function = new Acos();

            var input1 = "Jan 17, 2011 2:00 am";
            var input2 = "June 5, 2017 11:00 pm";
            var input3 = "Jan 17, 2011 2:00:00 am";
            var input4 = "June 5, 2017 11:00:00 pm";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result2.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result3.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result4.Result).Type);
        }
Пример #16
0
        public void AcosHandlesPi()
        {
            var function = new Acos();
            var Pi       = System.Math.PI;

            var input1 = Pi;
            var input2 = Pi / 2;
            var input3 = 2 * Pi;
            var input4 = 60 * Pi / 180;

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result2.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result3.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result4.Result).Type);
        }
Пример #17
0
 void CreateOperators()
 {
     // Only one of each operation Token needs to be created
     opAdd          = new Add(workStack);
     opSubtract     = new Subtract(workStack);
     opMultiply     = new Multiply(workStack);
     opDivide       = new Divide(workStack);
     opPower        = new Power(workStack);
     opLeftBracket  = new LeftBracket();
     opRightBracket = new RightBracket();
     opUnaryMinus   = new UnaryMinus(workStack);
     opUnaryPlus    = new UnaryPlus();
     opFactorial    = new Factorial(workStack);
     opSqrt         = new Sqrt(workStack);
     opSin          = new Sin(workStack);
     opCos          = new Cos(workStack);
     opTan          = new Tan(workStack);
     opLog          = new Log(workStack);
     opAsin         = new Asin(workStack);
     opAcos         = new Acos(workStack);
     opAtan         = new Atan(workStack);
     functions      = new Dictionary <string, Function>
     {
         { "sqrt", opSqrt },
         { "sin", opSin },
         { "cos", opCos },
         { "tan", opTan },
         { "log", opLog },
         { "asin", opAsin },
         { "acos", opAcos },
         { "atan", opAtan }
     };
     binaryOperators = new Dictionary <char, BinaryOperator>
     {
         { plusChar, opAdd },
         { minusChar, opSubtract },
         { multiplyChar, opMultiply },
         { divideChar, opDivide },
         { powerChar, opPower }
     };
 }
Пример #18
0
        public void AcosIsGivenValuesRanginFromNegative10to10()
        {
            var function = new Acos();

            var input1 = -10;
            var input2 = -1;
            var input3 = 0;
            var input4 = 1;
            var input5 = 10;

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);
            var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result1.Result).Type);
            Assert.AreEqual(3.141592654, System.Math.Round(result2.ResultNumeric, 9));
            Assert.AreEqual(1.570796327, result3.ResultNumeric, .00001);
            Assert.AreEqual(0, result4.ResultNumeric);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result5.Result).Type);
        }
Пример #19
0
        public void AcosHandlesDoublesCorrectly()
        {
            var function = new Acos();

            var input1 = 0.5;
            var input2 = 0.25;
            var input3 = 0.9;
            var input4 = -0.9;
            var input5 = ".5";

            var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext);
            var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext);
            var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext);
            var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext);
            var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext);

            Assert.AreEqual(1.047197551, System.Math.Round(result1.ResultNumeric, 9));
            Assert.AreEqual(1.318116072, System.Math.Round(result2.ResultNumeric, 9));
            Assert.AreEqual(0.451026812, System.Math.Round(result3.ResultNumeric, 9));
            Assert.AreEqual(2.690565842, System.Math.Round(result4.ResultNumeric, 9));
            Assert.AreEqual(1.047197551, System.Math.Round(result5.ResultNumeric, 9));
        }
Пример #20
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["rank"]        = new Rank();
     Functions["rank.eq"]     = new Rank();
     Functions["rank.avg"]    = new Rank(true);
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     // Logical
     Functions["if"]      = new If();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
Пример #21
0
 public void NegativeLgTests()
 {
     var calculator = new Acos();
     var result     = calculator.Calculate(10);
 }
Пример #22
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["textjoin"]    = new Textjoin();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value(CultureInfo.CurrentCulture);
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     Functions["dollar"]      = new Dollar();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["aggregate"]       = new Aggregate();
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["permut"]          = new Permut();
     Functions["permutationa"]    = new Permutationa();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdeva"]          = new Stdeva();
     Functions["stdevp"]          = new StdevP();
     Functions["stdevpa"]         = new Stdevpa();
     Functions["stdev.s"]         = new StdevDotS();
     Functions["stdev.p"]         = new StdevDotP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mode"]            = new Mode();
     Functions["mode.sngl"]       = new ModeSngl();
     Functions["mround"]          = new Mround();
     Functions["multinomial"]     = new Multinomial();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new RankEq();
     Functions["rank.avg"]        = new RankAvg();
     Functions["percentile"]      = new Percentile();
     Functions["percentile.inc"]  = new PercentileInc();
     Functions["percentile.exc"]  = new PercentileExc();
     Functions["quartile"]        = new Quartile();
     Functions["quartile.inc"]    = new QuartileInc();
     Functions["quartile.exc"]    = new QuartileExc();
     Functions["percentrank"]     = new Percentrank();
     Functions["percentrank.inc"] = new PercentrankInc();
     Functions["percentrank.exc"] = new PercentrankExc();
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["covar"]           = new Covar();
     Functions["covariance.p"]    = new CovarianceP();
     Functions["covariance.s"]    = new CovarianceS();
     Functions["var"]             = new Var();
     Functions["vara"]            = new Vara();
     Functions["var.s"]           = new VarDotS();
     Functions["varp"]            = new VarP();
     Functions["varpa"]           = new Varpa();
     Functions["var.p"]           = new VarDotP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["maxifs"]  = new MaxIfs();
     Functions["minifs"]  = new MinIfs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     Functions["xor"]     = new Xor();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["datedif"]          = new DateDif();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["cumipmt"]    = new Cumipmt();
     Functions["cumprinc"]   = new Cumprinc();
     Functions["dollarde"]   = new DollarDe();
     Functions["dollarfr"]   = new DollarFr();
     Functions["ddb"]        = new Ddb();
     Functions["effect"]     = new Effect();
     Functions["fvschedule"] = new FvSchedule();
     Functions["pduration"]  = new Pduration();
     Functions["rri"]        = new Rri();
     Functions["pmt"]        = new Pmt();
     Functions["ppmt"]       = new Ppmt();
     Functions["ipmt"]       = new Ipmt();
     Functions["ispmt"]      = new IsPmt();
     Functions["pv"]         = new Pv();
     Functions["fv"]         = new Fv();
     Functions["npv"]        = new Npv();
     Functions["rate"]       = new Rate();
     Functions["nper"]       = new Nper();
     Functions["nominal"]    = new Nominal();
     Functions["irr"]        = new Irr();
     Functions["mirr"]       = new Mirr();
     Functions["xirr"]       = new Xirr();
     Functions["sln"]        = new Sln();
     Functions["syd"]        = new Syd();
     Functions["xnpv"]       = new Xnpv();
     Functions["coupdays"]   = new Coupdays();
     Functions["coupdaysnc"] = new Coupdaysnc();
     Functions["coupdaybs"]  = new Coupdaybs();
     Functions["coupnum"]    = new Coupnum();
     Functions["coupncd"]    = new Coupncd();
     Functions["couppcd"]    = new Couppcd();
     Functions["price"]      = new Price();
     Functions["yield"]      = new Yield();
     Functions["yieldmat"]   = new Yieldmat();
     Functions["duration"]   = new Duration();
     Functions["disc"]       = new Disc();
     //Engineering
     Functions["bitand"]       = new BitAnd();
     Functions["bitor"]        = new BitOr();
     Functions["bitxor"]       = new BitXor();
     Functions["bitlshift"]    = new BitLshift();
     Functions["bitrshift"]    = new BitRshift();
     Functions["convert"]      = new ConvertFunction();
     Functions["bin2dec"]      = new Bin2Dec();
     Functions["bin2hex"]      = new Bin2Hex();
     Functions["bin2oct"]      = new Bin2Oct();
     Functions["dec2bin"]      = new Dec2Bin();
     Functions["dec2hex"]      = new Dec2Hex();
     Functions["dec2oct"]      = new Dec2Oct();
     Functions["hex2bin"]      = new Hex2Bin();
     Functions["hex2dec"]      = new Hex2Dec();
     Functions["hex2oct"]      = new Hex2Oct();
     Functions["oct2bin"]      = new Oct2Bin();
     Functions["oct2dec"]      = new Oct2Dec();
     Functions["oct2hex"]      = new Oct2Hex();
     Functions["delta"]        = new Delta();
     Functions["erf"]          = new Erf();
     Functions["erf.precise"]  = new ErfPrecise();
     Functions["erfc"]         = new Erfc();
     Functions["erfc.precise"] = new ErfcPrecise();
     Functions["besseli"]      = new BesselI();
     Functions["besselj"]      = new BesselJ();
     Functions["besselk"]      = new BesselK();
     Functions["bessely"]      = new BesselY();
 }
Пример #23
0
 public MySqlFunctionManager(bool allowFuncDefChange)
 {
     this.allowFuncDefChange                = allowFuncDefChange;
     parsingStrateg["CAST"]                 = FunctionParsingStrategy.Cast;
     parsingStrateg["POSITION"]             = FunctionParsingStrategy.Position;
     parsingStrateg["SUBSTR"]               = FunctionParsingStrategy.Substring;
     parsingStrateg["SUBSTRING"]            = FunctionParsingStrategy.Substring;
     parsingStrateg["TRIM"]                 = FunctionParsingStrategy.Trim;
     parsingStrateg["AVG"]                  = FunctionParsingStrategy.Avg;
     parsingStrateg["COUNT"]                = FunctionParsingStrategy.Count;
     parsingStrateg["GROUP_CONCAT"]         = FunctionParsingStrategy.GroupConcat;
     parsingStrateg["MAX"]                  = FunctionParsingStrategy.Max;
     parsingStrateg["MIN"]                  = FunctionParsingStrategy.Min;
     parsingStrateg["SUM"]                  = FunctionParsingStrategy.Sum;
     parsingStrateg["ROW"]                  = FunctionParsingStrategy.Row;
     parsingStrateg["CHAR"]                 = FunctionParsingStrategy.Char;
     parsingStrateg["CONVERT"]              = FunctionParsingStrategy.Convert;
     parsingStrateg["EXTRACT"]              = FunctionParsingStrategy.Extract;
     parsingStrateg["TIMESTAMPADD"]         = FunctionParsingStrategy.Timestampadd;
     parsingStrateg["TIMESTAMPDIFF"]        = FunctionParsingStrategy.Timestampdiff;
     parsingStrateg["GET_FORMAT"]           = FunctionParsingStrategy.GetFormat;
     functionPrototype["ABS"]               = new Abs(null);
     functionPrototype["ACOS"]              = new Acos(null);
     functionPrototype["ADDDATE"]           = new Adddate(null);
     functionPrototype["ADDTIME"]           = new Addtime(null);
     functionPrototype["AES_DECRYPT"]       = new AesDecrypt(null);
     functionPrototype["AES_ENCRYPT"]       = new AesEncrypt(null);
     functionPrototype["ANALYSE"]           = new Analyse(null);
     functionPrototype["ASCII"]             = new Ascii(null);
     functionPrototype["ASIN"]              = new Asin(null);
     functionPrototype["ATAN2"]             = new Atan2(null);
     functionPrototype["ATAN"]              = new Atan(null);
     functionPrototype["BENCHMARK"]         = new Benchmark(null);
     functionPrototype["BIN"]               = new Bin(null);
     functionPrototype["BIT_AND"]           = new BitAnd(null);
     functionPrototype["BIT_COUNT"]         = new BitCount(null);
     functionPrototype["BIT_LENGTH"]        = new BitLength(null);
     functionPrototype["BIT_OR"]            = new BitOR(null);
     functionPrototype["BIT_XOR"]           = new BitXor(null);
     functionPrototype["CEIL"]              = new Ceiling(null);
     functionPrototype["CEILING"]           = new Ceiling(null);
     functionPrototype["CHAR_LENGTH"]       = new CharLength(null);
     functionPrototype["CHARACTER_LENGTH"]  = new CharLength(null);
     functionPrototype["CHARSET"]           = new Charset(null);
     functionPrototype["COALESCE"]          = new Coalesce(null);
     functionPrototype["COERCIBILITY"]      = new Coercibility(null);
     functionPrototype["COLLATION"]         = new Collation(null);
     functionPrototype["COMPRESS"]          = new Compress(null);
     functionPrototype["CONCAT_WS"]         = new ConcatWs(null);
     functionPrototype["CONCAT"]            = new Concat(null);
     functionPrototype["CONNECTION_ID"]     = new ConnectionId(null);
     functionPrototype["CONV"]              = new Conv(null);
     functionPrototype["CONVERT_TZ"]        = new ConvertTz(null);
     functionPrototype["COS"]               = new Cos(null);
     functionPrototype["COT"]               = new Cot(null);
     functionPrototype["CRC32"]             = new Crc32(null);
     functionPrototype["CURDATE"]           = new Curdate();
     functionPrototype["CURRENT_DATE"]      = new Curdate();
     functionPrototype["CURRENT_TIME"]      = new Curtime();
     functionPrototype["CURTIME"]           = new Curtime();
     functionPrototype["CURRENT_TIMESTAMP"] = new Now();
     functionPrototype["CURRENT_USER"]      = new CurrentUser();
     functionPrototype["CURTIME"]           = new Curtime();
     functionPrototype["DATABASE"]          = new Database(null);
     functionPrototype["DATE_ADD"]          = new DateAdd(null);
     functionPrototype["DATE_FORMAT"]       = new DateFormat(null);
     functionPrototype["DATE_SUB"]          = new DateSub(null);
     functionPrototype["DATE"]              = new Date(null);
     functionPrototype["DATEDIFF"]          = new Datediff(null);
     functionPrototype["DAY"]               = new Dayofmonth(null);
     functionPrototype["DAYOFMONTH"]        = new Dayofmonth(null);
     functionPrototype["DAYNAME"]           = new Dayname(null);
     functionPrototype["DAYOFWEEK"]         = new Dayofweek(null);
     functionPrototype["DAYOFYEAR"]         = new Dayofyear(null);
     functionPrototype["DECODE"]            = new Decode(null);
     functionPrototype["DEFAULT"]           = new Default(null);
     functionPrototype["DEGREES"]           = new Degrees(null);
     functionPrototype["DES_DECRYPT"]       = new DesDecrypt(null);
     functionPrototype["DES_ENCRYPT"]       = new DesEncrypt(null);
     functionPrototype["ELT"]               = new Elt(null);
     functionPrototype["ENCODE"]            = new Encode(null);
     functionPrototype["ENCRYPT"]           = new Encrypt(null);
     functionPrototype["EXP"]               = new Exp(null);
     functionPrototype["EXPORT_SET"]        = new ExportSet(null);
     // functionPrototype.put("EXTRACT", new Extract(null));
     functionPrototype["EXTRACTVALUE"]  = new ExtractValue(null);
     functionPrototype["FIELD"]         = new Field(null);
     functionPrototype["FIND_IN_SET"]   = new FindInSet(null);
     functionPrototype["FLOOR"]         = new Floor(null);
     functionPrototype["FORMAT"]        = new Format(null);
     functionPrototype["FOUND_ROWS"]    = new FoundRows(null);
     functionPrototype["FROM_DAYS"]     = new FromDays(null);
     functionPrototype["FROM_UNIXTIME"] = new FromUnixtime(null);
     // functionPrototype.put("GET_FORMAT", new GetFormat(null));
     functionPrototype["GET_LOCK"]       = new GetLock(null);
     functionPrototype["GREATEST"]       = new Greatest(null);
     functionPrototype["HEX"]            = new Hex(null);
     functionPrototype["HOUR"]           = new Hour(null);
     functionPrototype["IF"]             = new IF(null);
     functionPrototype["IFNULL"]         = new IFNull(null);
     functionPrototype["INET_ATON"]      = new InetAton(null);
     functionPrototype["INET_NTOA"]      = new InetNtoa(null);
     functionPrototype["INSERT"]         = new Insert(null);
     functionPrototype["INSTR"]          = new Instr(null);
     functionPrototype["INTERVAL"]       = new Interval(null);
     functionPrototype["IS_FREE_LOCK"]   = new IsFreeLock(null);
     functionPrototype["IS_USED_LOCK"]   = new IsUsedLock(null);
     functionPrototype["ISNULL"]         = new IsNull(null);
     functionPrototype["LAST_DAY"]       = new LastDay(null);
     functionPrototype["LAST_INSERT_ID"] = new LastInsertId(null);
     functionPrototype["LCASE"]          = new Lower(null);
     functionPrototype["LEAST"]          = new Least(null);
     functionPrototype["LEFT"]           = new Left(null);
     functionPrototype["LENGTH"]         = new Length(null);
     functionPrototype["LN"]             = new Log(null);
     // Ln(X) equals Log(X)
     functionPrototype["LOAD_FILE"]       = new LoadFile(null);
     functionPrototype["LOCALTIME"]       = new Now();
     functionPrototype["LOCALTIMESTAMP"]  = new Now();
     functionPrototype["LOCATE"]          = new Locate(null);
     functionPrototype["LOG10"]           = new Log10(null);
     functionPrototype["LOG2"]            = new Log2(null);
     functionPrototype["LOG"]             = new Log(null);
     functionPrototype["LOWER"]           = new Lower(null);
     functionPrototype["LPAD"]            = new Lpad(null);
     functionPrototype["LTRIM"]           = new Ltrim(null);
     functionPrototype["MAKE_SET"]        = new MakeSet(null);
     functionPrototype["MAKEDATE"]        = new Makedate(null);
     functionPrototype["MAKETIME"]        = new Maketime(null);
     functionPrototype["MASTER_POS_WAIT"] = new MasterPosWait(null);
     functionPrototype["MD5"]             = new Md5(null);
     functionPrototype["MICROSECOND"]     = new Microsecond(null);
     functionPrototype["MID"]             = new Substring(null);
     functionPrototype["MINUTE"]          = new Minute(null);
     functionPrototype["MONTH"]           = new Month(null);
     functionPrototype["MONTHNAME"]       = new Monthname(null);
     functionPrototype["NAME_CONST"]      = new NameConst(null);
     functionPrototype["NOW"]             = new Now();
     functionPrototype["NULLIF"]          = new NullIF(null);
     functionPrototype["OCT"]             = new Oct(null);
     functionPrototype["OCTET_LENGTH"]    = new Length(null);
     functionPrototype["OLD_PASSWORD"]    = new OldPassword(null);
     functionPrototype["ORD"]             = new Ord(null);
     functionPrototype["PASSWORD"]        = new Password(null);
     functionPrototype["PERIOD_ADD"]      = new PeriodAdd(null);
     functionPrototype["PERIOD_DIFF"]     = new PeriodDiff(null);
     functionPrototype["PI"]              = new PI(null);
     functionPrototype["POW"]             = new Pow(null);
     functionPrototype["POWER"]           = new Pow(null);
     functionPrototype["QUARTER"]         = new Quarter(null);
     functionPrototype["QUOTE"]           = new Quote(null);
     functionPrototype["RADIANS"]         = new Radians(null);
     functionPrototype["RAND"]            = new Rand(null);
     functionPrototype["RELEASE_LOCK"]    = new ReleaseLock(null);
     functionPrototype["REPEAT"]          = new Repeat(null);
     functionPrototype["REPLACE"]         = new Replace(null);
     functionPrototype["REVERSE"]         = new Reverse(null);
     functionPrototype["RIGHT"]           = new Right(null);
     functionPrototype["ROUND"]           = new Round(null);
     functionPrototype["ROW_COUNT"]       = new RowCount(null);
     functionPrototype["RPAD"]            = new Rpad(null);
     functionPrototype["RTRIM"]           = new Rtrim(null);
     functionPrototype["SCHEMA"]          = new Database(null);
     functionPrototype["SEC_TO_TIME"]     = new SecToTime(null);
     functionPrototype["SECOND"]          = new Second(null);
     functionPrototype["SESSION_USER"]    = new User(null);
     functionPrototype["SHA1"]            = new Sha1(null);
     functionPrototype["SHA"]             = new Sha1(null);
     functionPrototype["SHA2"]            = new Sha2(null);
     functionPrototype["SIGN"]            = new Sign(null);
     functionPrototype["SIN"]             = new Sin(null);
     functionPrototype["SLEEP"]           = new Sleep(null);
     functionPrototype["SOUNDEX"]         = new Soundex(null);
     functionPrototype["SPACE"]           = new Space(null);
     functionPrototype["SQRT"]            = new Sqrt(null);
     functionPrototype["STD"]             = new Std(null);
     functionPrototype["STDDEV_POP"]      = new StdDevPop(null);
     functionPrototype["STDDEV_SAMP"]     = new StdDevSamp(null);
     functionPrototype["STDDEV"]          = new StdDev(null);
     functionPrototype["STR_TO_DATE"]     = new StrToDate(null);
     functionPrototype["STRCMP"]          = new Strcmp(null);
     functionPrototype["SUBDATE"]         = new Subdate(null);
     functionPrototype["SUBSTRING_INDEX"] = new SubstringIndex(null);
     functionPrototype["SUBTIME"]         = new Subtime(null);
     functionPrototype["SYSDATE"]         = new Sysdate(null);
     functionPrototype["SYSTEM_USER"]     = new User(null);
     functionPrototype["TAN"]             = new Tan(null);
     functionPrototype["TIME_FORMAT"]     = new TimeFormat(null);
     functionPrototype["TIME_TO_SEC"]     = new TimeToSec(null);
     functionPrototype["TIME"]            = new Time(null);
     functionPrototype["TIMEDIFF"]        = new Timediff(null);
     functionPrototype["TIMESTAMP"]       = new Timestamp(null);
     // functionPrototype.put("TIMESTAMPADD", new Timestampadd(null));
     // functionPrototype.put("TIMESTAMPDIFF", new Timestampdiff(null));
     functionPrototype["TO_DAYS"]             = new ToDays(null);
     functionPrototype["TO_SECONDS"]          = new ToSeconds(null);
     functionPrototype["TRUNCATE"]            = new Truncate(null);
     functionPrototype["UCASE"]               = new Upper(null);
     functionPrototype["UNCOMPRESS"]          = new Uncompress(null);
     functionPrototype["UNCOMPRESSED_LENGTH"] = new UncompressedLength(null);
     functionPrototype["UNHEX"]               = new Unhex(null);
     functionPrototype["UNIX_TIMESTAMP"]      = new UnixTimestamp(null);
     functionPrototype["UPDATEXML"]           = new UpdateXml(null);
     functionPrototype["UPPER"]               = new Upper(null);
     functionPrototype["USER"]          = new User(null);
     functionPrototype["UTC_DATE"]      = new UtcDate(null);
     functionPrototype["UTC_TIME"]      = new UtcTime(null);
     functionPrototype["UTC_TIMESTAMP"] = new UtcTimestamp(null);
     functionPrototype["UUID_SHORT"]    = new UuidShort(null);
     functionPrototype["UUID"]          = new Uuid(null);
     functionPrototype["VALUES"]        = new Values(null);
     functionPrototype["VAR_POP"]       = new VarPop(null);
     functionPrototype["VAR_SAMP"]      = new VarSamp(null);
     functionPrototype["VARIANCE"]      = new Variance(null);
     functionPrototype["VERSION"]       = new Version(null);
     functionPrototype["WEEK"]          = new Week(null);
     functionPrototype["WEEKDAY"]       = new Weekday(null);
     functionPrototype["WEEKOFYEAR"]    = new Weekofyear(null);
     functionPrototype["YEAR"]          = new Year(null);
     functionPrototype["YEARWEEK"]      = new Yearweek(null);
 }
Пример #24
0
 public MySqlFunctionManager(bool allowFuncDefChange)
 {
     this.allowFuncDefChange = allowFuncDefChange;
     parsingStrateg["CAST"] = FunctionParsingStrategy.Cast;
     parsingStrateg["POSITION"] = FunctionParsingStrategy.Position;
     parsingStrateg["SUBSTR"] = FunctionParsingStrategy.Substring;
     parsingStrateg["SUBSTRING"] = FunctionParsingStrategy.Substring;
     parsingStrateg["TRIM"] = FunctionParsingStrategy.Trim;
     parsingStrateg["AVG"] = FunctionParsingStrategy.Avg;
     parsingStrateg["COUNT"] = FunctionParsingStrategy.Count;
     parsingStrateg["GROUP_CONCAT"] = FunctionParsingStrategy.GroupConcat;
     parsingStrateg["MAX"] = FunctionParsingStrategy.Max;
     parsingStrateg["MIN"] = FunctionParsingStrategy.Min;
     parsingStrateg["SUM"] = FunctionParsingStrategy.Sum;
     parsingStrateg["ROW"] = FunctionParsingStrategy.Row;
     parsingStrateg["CHAR"] = FunctionParsingStrategy.Char;
     parsingStrateg["CONVERT"] = FunctionParsingStrategy.Convert;
     parsingStrateg["EXTRACT"] = FunctionParsingStrategy.Extract;
     parsingStrateg["TIMESTAMPADD"] = FunctionParsingStrategy.Timestampadd;
     parsingStrateg["TIMESTAMPDIFF"] = FunctionParsingStrategy.Timestampdiff;
     parsingStrateg["GET_FORMAT"] = FunctionParsingStrategy.GetFormat;
     functionPrototype["ABS"] = new Abs(null);
     functionPrototype["ACOS"] = new Acos(null);
     functionPrototype["ADDDATE"] = new Adddate(null);
     functionPrototype["ADDTIME"] = new Addtime(null);
     functionPrototype["AES_DECRYPT"] = new AesDecrypt(null);
     functionPrototype["AES_ENCRYPT"] = new AesEncrypt(null);
     functionPrototype["ANALYSE"] = new Analyse(null);
     functionPrototype["ASCII"] = new Ascii(null);
     functionPrototype["ASIN"] = new Asin(null);
     functionPrototype["ATAN2"] = new Atan2(null);
     functionPrototype["ATAN"] = new Atan(null);
     functionPrototype["BENCHMARK"] = new Benchmark(null);
     functionPrototype["BIN"] = new Bin(null);
     functionPrototype["BIT_AND"] = new BitAnd(null);
     functionPrototype["BIT_COUNT"] = new BitCount(null);
     functionPrototype["BIT_LENGTH"] = new BitLength(null);
     functionPrototype["BIT_OR"] = new BitOR(null);
     functionPrototype["BIT_XOR"] = new BitXor(null);
     functionPrototype["CEIL"] = new Ceiling(null);
     functionPrototype["CEILING"] = new Ceiling(null);
     functionPrototype["CHAR_LENGTH"] = new CharLength(null);
     functionPrototype["CHARACTER_LENGTH"] = new CharLength(null);
     functionPrototype["CHARSET"] = new Charset(null);
     functionPrototype["COALESCE"] = new Coalesce(null);
     functionPrototype["COERCIBILITY"] = new Coercibility(null);
     functionPrototype["COLLATION"] = new Collation(null);
     functionPrototype["COMPRESS"] = new Compress(null);
     functionPrototype["CONCAT_WS"] = new ConcatWs(null);
     functionPrototype["CONCAT"] = new Concat(null);
     functionPrototype["CONNECTION_ID"] = new ConnectionId(null);
     functionPrototype["CONV"] = new Conv(null);
     functionPrototype["CONVERT_TZ"] = new ConvertTz(null);
     functionPrototype["COS"] = new Cos(null);
     functionPrototype["COT"] = new Cot(null);
     functionPrototype["CRC32"] = new Crc32(null);
     functionPrototype["CURDATE"] = new Curdate();
     functionPrototype["CURRENT_DATE"] = new Curdate();
     functionPrototype["CURRENT_TIME"] = new Curtime();
     functionPrototype["CURTIME"] = new Curtime();
     functionPrototype["CURRENT_TIMESTAMP"] = new Now();
     functionPrototype["CURRENT_USER"] = new CurrentUser();
     functionPrototype["CURTIME"] = new Curtime();
     functionPrototype["DATABASE"] = new Database(null);
     functionPrototype["DATE_ADD"] = new DateAdd(null);
     functionPrototype["DATE_FORMAT"] = new DateFormat(null);
     functionPrototype["DATE_SUB"] = new DateSub(null);
     functionPrototype["DATE"] = new Date(null);
     functionPrototype["DATEDIFF"] = new Datediff(null);
     functionPrototype["DAY"] = new Dayofmonth(null);
     functionPrototype["DAYOFMONTH"] = new Dayofmonth(null);
     functionPrototype["DAYNAME"] = new Dayname(null);
     functionPrototype["DAYOFWEEK"] = new Dayofweek(null);
     functionPrototype["DAYOFYEAR"] = new Dayofyear(null);
     functionPrototype["DECODE"] = new Decode(null);
     functionPrototype["DEFAULT"] = new Default(null);
     functionPrototype["DEGREES"] = new Degrees(null);
     functionPrototype["DES_DECRYPT"] = new DesDecrypt(null);
     functionPrototype["DES_ENCRYPT"] = new DesEncrypt(null);
     functionPrototype["ELT"] = new Elt(null);
     functionPrototype["ENCODE"] = new Encode(null);
     functionPrototype["ENCRYPT"] = new Encrypt(null);
     functionPrototype["EXP"] = new Exp(null);
     functionPrototype["EXPORT_SET"] = new ExportSet(null);
     // functionPrototype.put("EXTRACT", new Extract(null));
     functionPrototype["EXTRACTVALUE"] = new ExtractValue(null);
     functionPrototype["FIELD"] = new Field(null);
     functionPrototype["FIND_IN_SET"] = new FindInSet(null);
     functionPrototype["FLOOR"] = new Floor(null);
     functionPrototype["FORMAT"] = new Format(null);
     functionPrototype["FOUND_ROWS"] = new FoundRows(null);
     functionPrototype["FROM_DAYS"] = new FromDays(null);
     functionPrototype["FROM_UNIXTIME"] = new FromUnixtime(null);
     // functionPrototype.put("GET_FORMAT", new GetFormat(null));
     functionPrototype["GET_LOCK"] = new GetLock(null);
     functionPrototype["GREATEST"] = new Greatest(null);
     functionPrototype["HEX"] = new Hex(null);
     functionPrototype["HOUR"] = new Hour(null);
     functionPrototype["IF"] = new IF(null);
     functionPrototype["IFNULL"] = new IFNull(null);
     functionPrototype["INET_ATON"] = new InetAton(null);
     functionPrototype["INET_NTOA"] = new InetNtoa(null);
     functionPrototype["INSERT"] = new Insert(null);
     functionPrototype["INSTR"] = new Instr(null);
     functionPrototype["INTERVAL"] = new Interval(null);
     functionPrototype["IS_FREE_LOCK"] = new IsFreeLock(null);
     functionPrototype["IS_USED_LOCK"] = new IsUsedLock(null);
     functionPrototype["ISNULL"] = new IsNull(null);
     functionPrototype["LAST_DAY"] = new LastDay(null);
     functionPrototype["LAST_INSERT_ID"] = new LastInsertId(null);
     functionPrototype["LCASE"] = new Lower(null);
     functionPrototype["LEAST"] = new Least(null);
     functionPrototype["LEFT"] = new Left(null);
     functionPrototype["LENGTH"] = new Length(null);
     functionPrototype["LN"] = new Log(null);
     // Ln(X) equals Log(X)
     functionPrototype["LOAD_FILE"] = new LoadFile(null);
     functionPrototype["LOCALTIME"] = new Now();
     functionPrototype["LOCALTIMESTAMP"] = new Now();
     functionPrototype["LOCATE"] = new Locate(null);
     functionPrototype["LOG10"] = new Log10(null);
     functionPrototype["LOG2"] = new Log2(null);
     functionPrototype["LOG"] = new Log(null);
     functionPrototype["LOWER"] = new Lower(null);
     functionPrototype["LPAD"] = new Lpad(null);
     functionPrototype["LTRIM"] = new Ltrim(null);
     functionPrototype["MAKE_SET"] = new MakeSet(null);
     functionPrototype["MAKEDATE"] = new Makedate(null);
     functionPrototype["MAKETIME"] = new Maketime(null);
     functionPrototype["MASTER_POS_WAIT"] = new MasterPosWait(null);
     functionPrototype["MD5"] = new Md5(null);
     functionPrototype["MICROSECOND"] = new Microsecond(null);
     functionPrototype["MID"] = new Substring(null);
     functionPrototype["MINUTE"] = new Minute(null);
     functionPrototype["MONTH"] = new Month(null);
     functionPrototype["MONTHNAME"] = new Monthname(null);
     functionPrototype["NAME_CONST"] = new NameConst(null);
     functionPrototype["NOW"] = new Now();
     functionPrototype["NULLIF"] = new NullIF(null);
     functionPrototype["OCT"] = new Oct(null);
     functionPrototype["OCTET_LENGTH"] = new Length(null);
     functionPrototype["OLD_PASSWORD"] = new OldPassword(null);
     functionPrototype["ORD"] = new Ord(null);
     functionPrototype["PASSWORD"] = new Password(null);
     functionPrototype["PERIOD_ADD"] = new PeriodAdd(null);
     functionPrototype["PERIOD_DIFF"] = new PeriodDiff(null);
     functionPrototype["PI"] = new PI(null);
     functionPrototype["POW"] = new Pow(null);
     functionPrototype["POWER"] = new Pow(null);
     functionPrototype["QUARTER"] = new Quarter(null);
     functionPrototype["QUOTE"] = new Quote(null);
     functionPrototype["RADIANS"] = new Radians(null);
     functionPrototype["RAND"] = new Rand(null);
     functionPrototype["RELEASE_LOCK"] = new ReleaseLock(null);
     functionPrototype["REPEAT"] = new Repeat(null);
     functionPrototype["REPLACE"] = new Replace(null);
     functionPrototype["REVERSE"] = new Reverse(null);
     functionPrototype["RIGHT"] = new Right(null);
     functionPrototype["ROUND"] = new Round(null);
     functionPrototype["ROW_COUNT"] = new RowCount(null);
     functionPrototype["RPAD"] = new Rpad(null);
     functionPrototype["RTRIM"] = new Rtrim(null);
     functionPrototype["SCHEMA"] = new Database(null);
     functionPrototype["SEC_TO_TIME"] = new SecToTime(null);
     functionPrototype["SECOND"] = new Second(null);
     functionPrototype["SESSION_USER"] = new User(null);
     functionPrototype["SHA1"] = new Sha1(null);
     functionPrototype["SHA"] = new Sha1(null);
     functionPrototype["SHA2"] = new Sha2(null);
     functionPrototype["SIGN"] = new Sign(null);
     functionPrototype["SIN"] = new Sin(null);
     functionPrototype["SLEEP"] = new Sleep(null);
     functionPrototype["SOUNDEX"] = new Soundex(null);
     functionPrototype["SPACE"] = new Space(null);
     functionPrototype["SQRT"] = new Sqrt(null);
     functionPrototype["STD"] = new Std(null);
     functionPrototype["STDDEV_POP"] = new StdDevPop(null);
     functionPrototype["STDDEV_SAMP"] = new StdDevSamp(null);
     functionPrototype["STDDEV"] = new StdDev(null);
     functionPrototype["STR_TO_DATE"] = new StrToDate(null);
     functionPrototype["STRCMP"] = new Strcmp(null);
     functionPrototype["SUBDATE"] = new Subdate(null);
     functionPrototype["SUBSTRING_INDEX"] = new SubstringIndex(null);
     functionPrototype["SUBTIME"] = new Subtime(null);
     functionPrototype["SYSDATE"] = new Sysdate(null);
     functionPrototype["SYSTEM_USER"] = new User(null);
     functionPrototype["TAN"] = new Tan(null);
     functionPrototype["TIME_FORMAT"] = new TimeFormat(null);
     functionPrototype["TIME_TO_SEC"] = new TimeToSec(null);
     functionPrototype["TIME"] = new Time(null);
     functionPrototype["TIMEDIFF"] = new Timediff(null);
     functionPrototype["TIMESTAMP"] = new Timestamp(null);
     // functionPrototype.put("TIMESTAMPADD", new Timestampadd(null));
     // functionPrototype.put("TIMESTAMPDIFF", new Timestampdiff(null));
     functionPrototype["TO_DAYS"] = new ToDays(null);
     functionPrototype["TO_SECONDS"] = new ToSeconds(null);
     functionPrototype["TRUNCATE"] = new Truncate(null);
     functionPrototype["UCASE"] = new Upper(null);
     functionPrototype["UNCOMPRESS"] = new Uncompress(null);
     functionPrototype["UNCOMPRESSED_LENGTH"] = new UncompressedLength(null);
     functionPrototype["UNHEX"] = new Unhex(null);
     functionPrototype["UNIX_TIMESTAMP"] = new UnixTimestamp(null);
     functionPrototype["UPDATEXML"] = new UpdateXml(null);
     functionPrototype["UPPER"] = new Upper(null);
     functionPrototype["USER"] = new User(null);
     functionPrototype["UTC_DATE"] = new UtcDate(null);
     functionPrototype["UTC_TIME"] = new UtcTime(null);
     functionPrototype["UTC_TIMESTAMP"] = new UtcTimestamp(null);
     functionPrototype["UUID_SHORT"] = new UuidShort(null);
     functionPrototype["UUID"] = new Uuid(null);
     functionPrototype["VALUES"] = new Values(null);
     functionPrototype["VAR_POP"] = new VarPop(null);
     functionPrototype["VAR_SAMP"] = new VarSamp(null);
     functionPrototype["VARIANCE"] = new Variance(null);
     functionPrototype["VERSION"] = new Version(null);
     functionPrototype["WEEK"] = new Week(null);
     functionPrototype["WEEKDAY"] = new Weekday(null);
     functionPrototype["WEEKOFYEAR"] = new Weekofyear(null);
     functionPrototype["YEAR"] = new Year(null);
     functionPrototype["YEARWEEK"] = new Yearweek(null);
 }
Пример #25
0
 public IEnumerator <ITask> AcosHandler(Acos acos)
 {
     acos.ResponsePort.Post(new Response(math.Acos(acos.Body.D)));
     yield break;
 }
Пример #26
0
 public virtual void loadFunctions(Rete engine)
 {
     Abs abs = new Abs();
     engine.declareFunction(abs);
     funcs.Add(abs);
     Acos acos = new Acos();
     engine.declareFunction(acos);
     funcs.Add(acos);
     Add add = new Add();
     engine.declareFunction(add);
     funcs.Add(add);
     Asin asin = new Asin();
     engine.declareFunction(asin);
     funcs.Add(asin);
     Atan atan = new Atan();
     engine.declareFunction(atan);
     funcs.Add(atan);
     Ceil ceil = new Ceil();
     engine.declareFunction(ceil);
     funcs.Add(ceil);
     Const cnst = new Const();
     engine.declareFunction(cnst);
     funcs.Add(cnst);
     Cos cos = new Cos();
     engine.declareFunction(cos);
     funcs.Add(cos);
     Degrees degrees = new Degrees();
     engine.declareFunction(degrees);
     funcs.Add(degrees);
     Divide div = new Divide();
     engine.declareFunction(div);
     funcs.Add(div);
     EqFunction eqf = new EqFunction();
     engine.declareFunction(eqf);
     funcs.Add(eqf);
     Evenp evenp = new Evenp();
     engine.declareFunction(evenp);
     funcs.Add(evenp);
     Exp exp = new Exp();
     engine.declareFunction(exp);
     funcs.Add(exp);
     Floor floor = new Floor();
     engine.declareFunction(floor);
     funcs.Add(floor);
     Greater gr = new Greater();
     engine.declareFunction(gr);
     funcs.Add(gr);
     GreaterOrEqual gre = new GreaterOrEqual();
     engine.declareFunction(gre);
     funcs.Add(gre);
     Less le = new Less();
     engine.declareFunction(le);
     funcs.Add(le);
     LessOrEqual leoe = new LessOrEqual();
     engine.declareFunction(leoe);
     funcs.Add(leoe);
     Log log = new Log();
     engine.declareFunction(log);
     funcs.Add(log);
     Max max = new Max();
     engine.declareFunction(max);
     funcs.Add(max);
     Min min = new Min();
     engine.declareFunction(min);
     funcs.Add(min);
     Multiply mul = new Multiply();
     engine.declareFunction(mul);
     funcs.Add(mul);
     NeqFunction neq = new NeqFunction();
     engine.declareFunction(neq);
     funcs.Add(neq);
     Oddp oddp = new Oddp();
     engine.declareFunction(oddp);
     funcs.Add(oddp);
     Pow pow = new Pow();
     engine.declareFunction(pow);
     funcs.Add(pow);
     Radians radians = new Radians();
     engine.declareFunction(radians);
     funcs.Add(radians);
     Random random = new Random();
     engine.declareFunction(random);
     funcs.Add(random);
     Rint rint = new Rint();
     engine.declareFunction(rint);
     funcs.Add(rint);
     Round round = new Round();
     engine.declareFunction(round);
     funcs.Add(round);
     Sin sin = new Sin();
     engine.declareFunction(sin);
     funcs.Add(sin);
     Sqrt sqrt = new Sqrt();
     engine.declareFunction(sqrt);
     funcs.Add(sqrt);
     Subtract sub = new Subtract();
     engine.declareFunction(sub);
     funcs.Add(sub);
     Tan tan = new Tan();
     engine.declareFunction(tan);
     funcs.Add(tan);
     // now we Add the functions under alias
     engine.declareFunction("+", add);
     engine.declareFunction("-", sub);
     engine.declareFunction("*", mul);
     engine.declareFunction("/", div);
     engine.declareFunction("**", pow);
     engine.declareFunction(">", gr);
     engine.declareFunction(">=", gre);
     engine.declareFunction("<", le);
     engine.declareFunction("<=", leoe);
 }
Пример #27
0
 void CreateOperators()
 {
     // Only one of each operation Token needs to be created
     opAdd = new Add(workStack);
     opSubtract = new Subtract(workStack);
     opMultiply = new Multiply(workStack);
     opDivide = new Divide(workStack);
     opPower = new Power(workStack);
     opBracket = new Bracket();
     opUnaryMinus = new UnaryMinus(workStack);
     opUnaryPlus = new UnaryPlus();
     opSqrt = new Sqrt(workStack);
     opSin = new Sin(workStack);
     opCos = new Cos(workStack);
     opTan = new Tan(workStack);
     opLog = new Log(workStack);
     opAsin = new Asin(workStack);
     opAcos = new Acos(workStack);
     opAtan = new Atan(workStack);
     functions = new Dictionary<string, Function>
     {
         {"sqr", opSqrt },
         {"sin", opSin },
         {"cos", opCos },
         {"tan", opTan },
         {"log", opLog },
         {"asin", opAsin },
         {"acos", opAcos },
         {"atan", opAtan }
     };
     binaryOperators = new Dictionary<char, BinaryOperator>
     {
         {'+', opAdd },
         {'-', opSubtract },
         {'*', opMultiply },
         {'/', opDivide },
         {'^',opPower }
     };
 }