当前位置: 首页>>代码示例>>C#>>正文


C# CalculationEngine.Calculate方法代码示例

本文整理汇总了C#中CalculationEngine.Calculate方法的典型用法代码示例。如果您正苦于以下问题:C# CalculationEngine.Calculate方法的具体用法?C# CalculationEngine.Calculate怎么用?C# CalculationEngine.Calculate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CalculationEngine的用法示例。


在下文中一共展示了CalculationEngine.Calculate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCalculateFormula1

        public void TestCalculateFormula1()
        {
            CalculationEngine engine = new CalculationEngine();
            double result = engine.Calculate("2+3");

            Assert.AreEqual(5.0, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例2: TestCalculateCosineFunctionInterpreted

        public void TestCalculateCosineFunctionInterpreted()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted);
            double result = engine.Calculate("cos(41)");

            Assert.AreEqual(Math.Cos(41.0), result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例3: TestCalculateFormulaVariableNotDefinedInterpreted

        public void TestCalculateFormulaVariableNotDefinedInterpreted()
        {
            Dictionary<string, double> variables = new Dictionary<string, double>();
            variables.Add("var1", 2.5);

            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted);
            double result = engine.Calculate("var1*var2", variables);
        }
开发者ID:plurby,项目名称:Jace,代码行数:8,代码来源:CalculationEngineTests.cs

示例4: TestCalculateFormulaVariableNotDefinedCompiled

        public void TestCalculateFormulaVariableNotDefinedCompiled()
        {
            Dictionary<string, double> variables = new Dictionary<string, double>();
            variables.Add("var1", 2.5);

            AssertExtensions.ThrowsException<VariableNotDefinedException>(() =>
                {
                    CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Compiled);
                    double result = engine.Calculate("var1*var2", variables);
                });
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:11,代码来源:CalculationEngineTests.cs

示例5: BenchMarkCalculationEngine

        private static void BenchMarkCalculationEngine(CalculationEngine engine, string functionText)
        {
            DateTime start = DateTime.Now;

            for (int i = 0; i < NumberOfTests; i++)
            {
                engine.Calculate(functionText);
            }

            DateTime end = DateTime.Now;

            Console.WriteLine("Total duration: {0}", end - start);
        }
开发者ID:plurby,项目名称:Jace,代码行数:13,代码来源:Program.cs

示例6: TestPiMultiplication

        public void TestPiMultiplication()
        {
            CalculationEngine engine = new CalculationEngine();
            double result = engine.Calculate("2 * pI");

            Assert.AreEqual(2 * Math.PI, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例7: TestNestedFunctions

        public void TestNestedFunctions()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture);

            double result = engine.Calculate("max(sin(67), cos(67))");
            Assert.AreEqual(-0.517769799789505, Math.Round(result, 15));
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例8: TestNegativeConstant

        public void TestNegativeConstant()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Compiled, true, false);
            double result = engine.Calculate("-100");

            Assert.AreEqual(-100.0, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例9: TestNotEqual2Interpreted

        public void TestNotEqual2Interpreted()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted);

            Dictionary<string, double> variables = new Dictionary<string, double>();
            variables.Add("var1", 2);
            variables.Add("var2", 2);

            double result = engine.Calculate("var1 ≠ 2", variables);
            Assert.AreEqual(0.0, result);
        }
开发者ID:CasperWollesen,项目名称:Jace,代码行数:11,代码来源:CalculationEngineTests.cs

示例10: TestUnaryMinus5Interpreted

        public void TestUnaryMinus5Interpreted()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted, true, false);
            double result = engine.Calculate("-(1*2)^3");

            Assert.AreEqual(-8.0, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例11: TestCalculateSineFunctionCompiled

        public void TestCalculateSineFunctionCompiled()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Compiled, true, false);
            double result = engine.Calculate("sin(14)");

            Assert.AreEqual(Math.Sin(14.0), result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例12: TestCalculatePowInterpreted

        public void TestCalculatePowInterpreted()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted);
            double result = engine.Calculate("2^3.0");

            Assert.AreEqual(8.0, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例13: TestCalculateModuloInterpreted

        public void TestCalculateModuloInterpreted()
        {
            CalculationEngine engine =
                new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted, false, false);
            double result = engine.Calculate("5 % 3.0");

            Assert.AreEqual(2.0, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:8,代码来源:CalculationEngineTests.cs

示例14: TestCalculateLognFunctionInterpreted

        public void TestCalculateLognFunctionInterpreted()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted, true, false);
            double result = engine.Calculate("logn(14, 3)");

            Assert.AreEqual(Math.Log(14.0, 3.0), result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例15: TestVariableCaseNonFunc

        public void TestVariableCaseNonFunc()
        {
            CalculationEngine engine = new CalculationEngine();

            Dictionary<string, double> variables = new Dictionary<string, double>();
            variables.Add("var1", 2);
            variables.Add("otherVariable", 4.2);

            double result = engine.Calculate("var1+2/(3*otherVariablE)", variables);
        }
开发者ID:CasperWollesen,项目名称:Jace,代码行数:10,代码来源:CalculationEngineTests.cs


注:本文中的CalculationEngine.Calculate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。