本文整理汇总了C#中IEvaluator.SetVariable方法的典型用法代码示例。如果您正苦于以下问题:C# IEvaluator.SetVariable方法的具体用法?C# IEvaluator.SetVariable怎么用?C# IEvaluator.SetVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvaluator
的用法示例。
在下文中一共展示了IEvaluator.SetVariable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: increaseLevel
private void increaseLevel(IEvaluator evaluator)
{
if (evaluator.GetVariable(LEVEL_VARIABLE) == null)
{
evaluator.SetVariable(LEVEL_VARIABLE, 1);
}
else
{
evaluator.SetVariable(LEVEL_VARIABLE, 1 + (int)evaluator.GetVariable(LEVEL_VARIABLE));
}
}
示例2: Verify
public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
object savedTextValue = evaluator.GetVariable(TEXT_VARIABLE);
object savedHrefValue = evaluator.GetVariable(HREF_VARIABLE);
try
{
evaluator.SetVariable(TEXT_VARIABLE, commandCall.Element.Text);
evaluator.SetVariable(HREF_VARIABLE, getHref(commandCall.Element));
m_command.Verify(commandCall, evaluator, resultRecorder);
}
finally
{
evaluator.SetVariable(TEXT_VARIABLE, savedTextValue);
evaluator.SetVariable(HREF_VARIABLE, savedHrefValue);
}
}
示例3: Verify
public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
var pattern = new Regex("(#.+?) *: *(.+)");
var matcher = pattern.Match(commandCall.Expression);
if (!matcher.Success)
{
throw new InvalidOperationException("The expression for a \"verifyRows\" should be of the form: #var : collectionExpr");
}
var loopVariableName = matcher.Groups[1].Value;
var iterableExpression = matcher.Groups[2].Value;
var obj = evaluator.Evaluate(iterableExpression);
Check.NotNull(obj, "Expression returned null (should be an IEnumerable).");
Check.IsTrue(obj is IEnumerable, obj.GetType() + " is not IEnumerable");
Check.IsTrue(!(obj is IDictionary), obj.GetType() + " does not have a predictable iteration order");
var iterable = (IEnumerable)obj;
var tableSupport = new TableSupport(commandCall);
var detailRows = tableSupport.GetDetailRows();
int index = 0;
foreach (var loopVar in iterable)
{
evaluator.SetVariable(loopVariableName, loopVar);
Row detailRow;
if (detailRows.Count > index)
{
detailRow = detailRows[index];
}
else
{
detailRow = tableSupport.AddDetailRow();
OnSurplusRow(detailRow.RowElement);
}
tableSupport.CopyCommandCallsTo(detailRow);
commandCall.Children.Verify(evaluator, resultRecorder);
index++;
}
for (; index < detailRows.Count; index++) {
Row detailRow = detailRows[index];
resultRecorder.Record(Result.Failure);
OnMissingRow(detailRow.RowElement);
}
}
示例4: Setup
public void Setup(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside a 'set' is not supported");
evaluator.SetVariable(commandCall.Expression, commandCall.Element.Text);
}
示例5: SetLanguage
private static void SetLanguage(string language)
{
WriteLine(ConsoleColor.Cyan, "Language: " + language);
switch (language.Trim().ToLower())
{
case "vb":
ev = new VbEvaluator();
break;
case "excel":
ev = new ExcelEvaluator();
break;
case "cs":
ev = new CSharpEvaluator();
break;
case "javascript":
ev = new JavascriptEvaluator();
break;
case "math":
ev = new MathEvaluator();
break;
default:
WriteLine(ConsoleColor.Red, "Unknown language " + language);
break;
}
ev.SetVariable("arr", new[] { 2, 4, 6 });
}
示例6: decreaseLevel
private void decreaseLevel(IEvaluator evaluator)
{
evaluator.SetVariable(LEVEL_VARIABLE, (int)evaluator.GetVariable(LEVEL_VARIABLE) - 1);
}