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


C# IEvaluator.SetVariable方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:concordion,项目名称:concordion-net,代码行数:11,代码来源:ListExecuteStrategy.cs

示例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);
     }
 }
开发者ID:ManiAzizzadeh,项目名称:Concordion.NET,代码行数:16,代码来源:LocalTextDecorator.cs

示例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);
            }
        }
开发者ID:ElviraH,项目名称:concordion-net,代码行数:48,代码来源:VerifyRowsCommand.cs

示例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);
 }
开发者ID:ElviraH,项目名称:concordion-net,代码行数:5,代码来源:SetCommand.cs

示例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 });
 }
开发者ID:elsupergomez,项目名称:Eval4,代码行数:26,代码来源:Program.cs

示例6: decreaseLevel

 private void decreaseLevel(IEvaluator evaluator)
 {
     evaluator.SetVariable(LEVEL_VARIABLE, (int)evaluator.GetVariable(LEVEL_VARIABLE) - 1);
 }
开发者ID:concordion,项目名称:concordion-net,代码行数:4,代码来源:ListExecuteStrategy.cs


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