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


C# IEvaluator.Evaluate方法代码示例

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


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

示例1: Verify

        public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            CommandCallList childCommands = commandCall.Children;
            childCommands.SetUp(evaluator, resultRecorder);
            childCommands.Execute(evaluator, resultRecorder);
            childCommands.Verify(evaluator, resultRecorder);

            String expression = commandCall.Expression;
            Object result = evaluator.Evaluate(expression);

            if (result != null && result is Boolean)
            {
                if ((Boolean) result)
                {
                    ProcessTrueResult(commandCall, resultRecorder);
                }
                else
                {
                    ProcessFalseResult(commandCall, resultRecorder);
                }
            }
            else
            {
                throw new InvalidExpressionException("Expression '" + expression + "' did not produce a boolean result (needed for assertTrue).");
            }
        }
开发者ID:concordion,项目名称:concordion-net,代码行数:26,代码来源:BooleanCommand.cs

示例2: Evaluate

        private static double[] Evaluate(IEvaluator evaluator, Function[] functions)
        {
            List<double> values = new List<double>();
            foreach (Function function in functions)
            {
                values.Add(evaluator.Evaluate(function));
            }

            return values.ToArray();
        }
开发者ID:mortenbakkedal,项目名称:SharpMath,代码行数:10,代码来源:Evaluator.cs

示例3: Execute

        public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside a 'run' is not supported");

            var element = commandCall.Element;

            var href = element.GetAttributeValue("href");
            Check.NotNull(href, "The 'href' attribute must be set for an element containing concordion:run");

            var runnerType = commandCall.Expression;
            var expression = element.GetAttributeValue("params", "concordion");

            if (expression != null)
            {
                evaluator.Evaluate(expression);
            }

            try
            {
                IRunner concordionRunner;
                Runners.TryGetValue(runnerType, out concordionRunner);

                // TODO - re-check this.
                Check.NotNull(concordionRunner, "The runner '" + runnerType + "' cannot be found. "
                        + "Choices: (1) Use 'concordion' as your runner (2) Ensure that the 'concordion.runner." + runnerType
                        + "' System property is set to a name of an IRunner implementation "
                        + "(3) Specify an assembly fully qualified class name of an IRunner implementation");

                var result = concordionRunner.Execute(evaluator.Fixture, commandCall.Resource, href).Result;

                if (result == Result.Success)
                {
                    resultRecorder.Success();
                    AnnounceSuccess(element);
                }
                else if (result == Result.Ignored)
                {
                    resultRecorder.Ignore();
                    AnnounceIgnored(element);
                }
                else
                {
                    resultRecorder.Failure(string.Format("test {0} failed", href), commandCall.Element.ToXml());
                    AnnounceFailure(element);
                }
            }
            catch (Exception e)
            {
                resultRecorder.Error(e);
                AnnounceError(e, element, expression);
            }
        }
开发者ID:concordion,项目名称:concordion-net,代码行数:52,代码来源:RunCommand.cs

示例4: 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();

            AnnounceExpressionEvaluated(commandCall.Element);

            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();
                    AnnounceSurplusRow(detailRow.RowElement);
                }
                tableSupport.CopyCommandCallsTo(detailRow);
                commandCall.Children.Verify(evaluator, resultRecorder);
                index++;
            }

            for (; index < detailRows.Count; index++) {
                Row detailRow = detailRows[index];
                resultRecorder.Record(Result.Failure);
                AnnounceMissingRow(detailRow.RowElement);
            }
        }
开发者ID:john-ross,项目名称:concordion-net,代码行数:50,代码来源:VerifyRowsCommand.cs

示例5: Verify

        public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'echo' is not supported");

            Object result = evaluator.Evaluate(commandCall.Expression);

            Element element = commandCall.Element;
            if (result != null)
            {
                element.AppendText(result.ToString());
            }
            else
            {
                Element child = new Element("em");
                child.AppendText("null");
                element.AppendChild(child);
            }
        }
开发者ID:ElviraH,项目名称:concordion-net,代码行数:18,代码来源:EchoCommand.cs

示例6: Verify

        public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported");

            Element element = commandCall.Element;

            object actual = evaluator.Evaluate(commandCall.Expression);
            string expected = element.Text;

            if (m_comparer.Compare(actual, expected) == 0)
            {
                resultRecorder.Record(Result.Success);
                OnSuccessReported(element);
            }
            else
            {
                resultRecorder.Record(Result.Failure);
                OnFailureReported(element, actual, expected);
            }
        }
开发者ID:ManiAzizzadeh,项目名称:Concordion.NET,代码行数:20,代码来源:AssertEqualsCommand.cs

示例7: Verify

        public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported");

            Element element = commandCall.Element;

            object actual = evaluator.Evaluate(commandCall.Expression);
            string expected = element.Text;

            if (this.m_Comparer.Compare(actual, expected) == 0)
            {
                resultRecorder.Success();
                AnnounceSuccess(element);
            }
            else
            {
                resultRecorder.Failure(string.Format("expected {0} but was {1}", expected, actual),
                                       element.ToXml());
                AnnounceFailure(element, expected, actual);
            }
        }
开发者ID:concordion,项目名称:concordion-net,代码行数:21,代码来源:AssertEqualsCommand.cs

示例8: Test

		protected override bool Test (IEvaluator condition, State state, ref bool currentState) {
			currentState = condition.Evaluate(state) || _startState;
			return(!currentState);
		}
开发者ID:tautologistics,项目名称:CDub.LogicEngine,代码行数:4,代码来源:Or.cs

示例9: Value

 /// <summary>
 /// Evaluates the function by assigning values to the variables.
 /// </summary>
 public double Value(IEvaluator evaluator)
 {
     // Consider removing this extra call?
     return evaluator.Evaluate(this);
 }
开发者ID:mortenbakkedal,项目名称:SharpMath,代码行数:8,代码来源:Function.cs


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