Пример #1
0
        public Evaluation EvaluateOperator(
            ExpressionOptions options, ValueToken op, Token?left, Token?right)
        {
            var validationError = ValidateOperatorTokens(options, op, left, right);

            if (validationError != null)
            {
                return(validationError);
            }

            var leftEval = left != null?Evaluate(options, left) : null;

            if (leftEval?.Error != null)
            {
                return(leftEval);
            }

            var rightEval = right != null?Evaluate(options, right) : null;

            if (rightEval?.Error != null)
            {
                return(rightEval);
            }

            return(ExecuteOperator.Invoke(op.Value, leftEval?.Result, rightEval?.Result));
        }
Пример #2
0
 public static bool IsMatch(ExecuteCommand command, ExecuteOperator<Cell> executor, Tree<Cell> parameters)
 {
     var processor = new CellProcessorBase();
     processor.AddOperator(new ParseMemberName());
     ((CellOperator) executor).Processor = processor;
     return executor.CanExecute(new TypedValue(new ExecuteContext(command, null, new TypedValue("stuff"))), parameters);
 }
Пример #3
0
        public static bool IsMatch(ExecuteCommand command, ExecuteOperator <Cell> executor, Tree <Cell> parameters)
        {
            var processor = new CellProcessorBase();

            processor.AddOperator(new ParseMemberName());
            ((CellOperator)executor).Processor = processor;
            return(executor.CanExecute(new TypedValue(new ExecuteContext(command, new TypedValue("stuff"))), parameters));
        }
Пример #4
0
        private void ExecuteOperation(ExecuteOperator <string> executeOperator, Tree <string> input, int branchCount)
        {
            TypedValue executeResult = TypedValue.Void;

            executeOperator.TryExecute(processor, TypedValue.Void, input, ref executeResult);
            result = (Tree <string>)executeResult.Value;
            Assert.IsFalse(result.IsLeaf);
            Assert.AreEqual(branchCount, result.Branches.Count);
            Assert.AreEqual("step", result.Branches[0].Value);
        }
Пример #5
0
        private void ExecuteOperation(ExecuteOperator <string> executeOperator, Tree <string> input, int branchCount)
        {
            TypedValue executeResult = TypedValue.Void;

            if (executeOperator.CanExecute(TypedValue.Void, input))
            {
                executeResult = executeOperator.Execute(TypedValue.Void, input);
            }
            result = executeResult.GetValue <Tree <string> >();
            Assert.IsFalse(result.IsLeaf);
            Assert.AreEqual(branchCount, result.Branches.Count);
            Assert.AreEqual("step", result.Branches[0].Value);
        }
Пример #6
0
 /// <summary>
 /// Gets the hash code for this object
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(OperatorString.GetHashCode() ^ ExecuteOperator.GetHashCode() ^ Side.GetHashCode());
 }
Пример #7
0
 private void ExecuteOperation(ExecuteOperator<string> executeOperator, Tree<string> input, int branchCount)
 {
     TypedValue executeResult = TypedValue.Void;
     executeOperator.TryExecute(processor, TypedValue.Void, input, ref executeResult);
     result = (Tree<string>)executeResult.Value;
     Assert.IsFalse(result.IsLeaf);
     Assert.AreEqual(branchCount, result.Branches.Count);
     Assert.AreEqual("step", result.Branches[0].Value);
 }
Пример #8
0
 private void ExecuteOperation(ExecuteOperator<string> executeOperator, Tree<string> input, int branchCount)
 {
     TypedValue executeResult = TypedValue.Void;
     if (executeOperator.CanExecute(TypedValue.Void, input)) {
         executeResult = executeOperator.Execute(TypedValue.Void, input);
     }
     result = executeResult.GetValue<Tree<string>>();
     Assert.IsFalse(result.IsLeaf);
     Assert.AreEqual(branchCount, result.Branches.Count);
     Assert.AreEqual("step", result.Branches[0].Value);
 }