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


C# CalculationEngine.Formula方法代码示例

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


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

示例1: BenchMarkCalculationEngineRandomFunctionBuild

        private static void BenchMarkCalculationEngineRandomFunctionBuild(CalculationEngine engine, List<string> functions, 
            int numberOfTests)
        {
            Random random = new Random();

            DateTime start = DateTime.Now;

            Parallel.ForEach(functions,(functionText)=>
                {
                    Func<int, int, int, double> function = (Func<int, int, int, double>)engine.Formula(functionText)
                        .Parameter("var1", DataType.Integer)
                        .Parameter("var2", DataType.Integer)
                        .Parameter("var3", DataType.Integer)
                        .Result(DataType.FloatingPoint)
                        .Build();

                    for (int i = 0; i < numberOfTests; i++)
                    {
                        function(random.Next(), random.Next(), random.Next());
                    }
                });

            DateTime end = DateTime.Now;

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

示例2: BenchMarkCalculationEngineFunctionBuild

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

            Func<int, int, int, double> function = (Func<int, int, int, double>)engine.Formula(functionText)
                .Parameter("var1", DataType.Integer)
                .Parameter("var2", DataType.Integer)
                .Parameter("something", DataType.Integer)
                .Result(DataType.FloatingPoint)
                .Build();

            Random random = new Random();

            for (int i = 0; i < NumberOfTests; i++)
            {
                function(random.Next(), random.Next(), random.Next());
            }

            DateTime end = DateTime.Now;

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

示例3: BenchMarkCalculationEngineRandomFunctionBuild

        private static void BenchMarkCalculationEngineRandomFunctionBuild(CalculationEngine engine, List<string> functions, 
            int numberOfTests)
        {
            Random random = new Random();

            DateTime start = DateTime.Now;

            List<Task> tasks = new List<Task>();

            foreach (string functionText in functions)
            {
                Task task = new Task(() =>
                {
                    Func<int, int, int, double> function = (Func<int, int, int, double>)engine.Formula(functionText)
                        .Parameter("var1", DataType.Integer)
                        .Parameter("var2", DataType.Integer)
                        .Parameter("var3", DataType.Integer)
                        .Result(DataType.FloatingPoint)
                        .Build();

                    for (int i = 0; i < numberOfTests; i++)
                    {
                        function(random.Next(), random.Next(), random.Next());
                    }
                });

                tasks.Add(task);
                task.Start();
            }

            Task.WaitAll(tasks.ToArray());

            DateTime end = DateTime.Now;

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

示例4: TestFormulaBuilderInvalidParameterName

 public void TestFormulaBuilderInvalidParameterName()
 {
     AssertExtensions.ThrowsException<ArgumentException>(() =>
         {
             CalculationEngine engine = new CalculationEngine();
             Func<int, double, double> function = (Func<int, double, double>)engine.Formula("sin+2")
                 .Parameter("sin", DataType.Integer)
                 .Build();
         });
 }
开发者ID:pcmichaels,项目名称:Jace,代码行数:10,代码来源:CalculationEngineTests.cs

示例5: TestFormulaBuilderDuplicateParameterName

 public void TestFormulaBuilderDuplicateParameterName()
 {
     AssertExtensions.ThrowsException<ArgumentException>(() =>
         {
             CalculationEngine engine = new CalculationEngine();
             Func<int, double, double> function = (Func<int, double, double>)engine.Formula("var1+2")
                 .Parameter("var1", DataType.Integer)
                 .Parameter("var1", DataType.FloatingPoint)
                 .Build();
         });
 }
开发者ID:pcmichaels,项目名称:Jace,代码行数:11,代码来源:CalculationEngineTests.cs

示例6: TestFormulaBuilderCompiled

        public void TestFormulaBuilderCompiled()
        {
            CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Compiled);
            Func<int, double, double> function = (Func<int, double, double>)engine.Formula("var1+2*(3*age)")
                .Parameter("var1", DataType.Integer)
                .Parameter("age", DataType.FloatingPoint)
                .Result(DataType.FloatingPoint)
                .Build();

            double result = function(2, 4);
            Assert.AreEqual(26.0, result);
        }
开发者ID:pcmichaels,项目名称:Jace,代码行数:12,代码来源:CalculationEngineTests.cs

示例7: TestFormulaBuilderInvalidParameterName

 public void TestFormulaBuilderInvalidParameterName()
 {
     CalculationEngine engine = new CalculationEngine();
     Func<int, double, double> function = (Func<int, double, double>)engine.Formula("sin+2")
         .Parameter("sin", DataType.Integer)
         .Build();
 }
开发者ID:plurby,项目名称:Jace,代码行数:7,代码来源:CalculationEngineTests.cs

示例8: TestFormulaBuilderDuplicateParameterName

 public void TestFormulaBuilderDuplicateParameterName()
 {
     CalculationEngine engine = new CalculationEngine();
     Func<int, double, double> function = (Func<int, double, double>)engine.Formula("var1+2")
         .Parameter("var1", DataType.Integer)
         .Parameter("var1", DataType.FloatingPoint)
         .Build();
 }
开发者ID:plurby,项目名称:Jace,代码行数:8,代码来源:CalculationEngineTests.cs


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