本文整理汇总了C#中CalculationEngine.BatchLoad方法的典型用法代码示例。如果您正苦于以下问题:C# CalculationEngine.BatchLoad方法的具体用法?C# CalculationEngine.BatchLoad怎么用?C# CalculationEngine.BatchLoad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CalculationEngine
的用法示例。
在下文中一共展示了CalculationEngine.BatchLoad方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBatchLoad
public void TestBatchLoad()
{
// Test that we can add expressions in any order
CalculationEngine engine = new CalculationEngine();
ExpressionContext context = new ExpressionContext();
int interest = 2;
context.Variables.Add("interest", interest);
BatchLoader loader = engine.CreateBatchLoader();
loader.Add("c", "a + b", context);
loader.Add("a", "100 + interest", context);
loader.Add("b", "a + 1 + a", context);
// Test an expression with a reference in a string
loader.Add("d", "\"str \\\" str\" + a + \"b\"", context);
engine.BatchLoad(loader);
int result = engine.GetResult<int>("b");
Assert.AreEqual((100 + interest) + 1 + (100 + interest), result);
interest = 300;
context.Variables["interest"] = interest;
engine.Recalculate("a");
result = engine.GetResult<int>("b");
Assert.AreEqual((100 + interest) + 1 + (100 + interest), result);
result = engine.GetResult<int>("c");
Assert.AreEqual((100 + interest) + 1 + (100 + interest) + (100 + interest), result);
Assert.AreEqual("str \" str400b", engine.GetResult<string>("d"));
}