本文整理汇总了C#中CalculationEngine.Build方法的典型用法代码示例。如果您正苦于以下问题:C# CalculationEngine.Build方法的具体用法?C# CalculationEngine.Build怎么用?C# CalculationEngine.Build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CalculationEngine
的用法示例。
在下文中一共展示了CalculationEngine.Build方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBuild
public void TestBuild()
{
CalculationEngine engine = new CalculationEngine();
Func<Dictionary<string, double>, double> function = engine.Build("var1+2*(3*age)");
Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2);
variables.Add("age", 4);
double result = function(variables);
Assert.AreEqual(26.0, result);
}
示例2: TestVariableCaseFuncInterpreted
public void TestVariableCaseFuncInterpreted()
{
CalculationEngine engine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Interpreted);
Func<Dictionary<string, double>, double> formula = engine.Build("var1+2/(3*otherVariablE)");
Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2);
variables.Add("otherVariable", 4.2);
double result = formula(variables);
}
示例3: ExecuteCalculate
private void ExecuteCalculate()
{
CalculationEngine engine = new CalculationEngine();
var formula = engine.Build(this.Formula);
this.Result = formula(this.Variables.ToDictionary(k => k.Name, v => v.Value));
}