Exemple #1
0
        protected virtual Expression OnVisit(AndAlso expression)
        {
            var left  = OnVisit(expression.Left);
            var right = OnVisit(expression.Right);

            if (left != expression.Left || right != expression.Right)
            {
                return(CopyTrivia(new AndAlso(left, right), expression));
            }
            return(expression);
        }
Exemple #2
0
        private static Activity HandleBinaryExpression <TLeft, TRight, TResult>(BinaryOperator op, TestExpression left, TestExpression right)
        {
            Activity           we           = null;
            InArgument <TLeft> leftArgument = (InArgument <TLeft>)TestExpression.GetInArgumentFromExpectedNode <TLeft>(left);

            leftArgument.EvaluationOrder = 0;
            InArgument <TRight> rightArgument = (InArgument <TRight>)TestExpression.GetInArgumentFromExpectedNode <TRight>(right);

            rightArgument.EvaluationOrder = 1;

            switch (op)
            {
            case BinaryOperator.Add:
                we = new Add <TLeft, TRight, TResult>()
                {
                    Checked = false,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.And:
                we = new And <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.AndAlso:
                we = new AndAlso()
                {
                    Left  = TestExpression.GetWorkflowElementFromExpectedNode <bool>(left),
                    Right = TestExpression.GetWorkflowElementFromExpectedNode <bool>(right)
                };
                break;

            case BinaryOperator.CheckedAdd:
                we = new Add <TLeft, TRight, TResult>()
                {
                    Checked = true,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.CheckedMultiply:
                we = new Multiply <TLeft, TRight, TResult>()
                {
                    Checked = true,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.CheckedSubtract:
                we = new Subtract <TLeft, TRight, TResult>()
                {
                    Checked = true,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.Divide:
                we = new Divide <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.Equal:
                we = new Equal <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.GreaterThan:
                we = new GreaterThan <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.GreaterThanOrEqual:
                we = new GreaterThanOrEqual <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.LessThan:
                we = new LessThan <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.LessThanOrEqual:
                we = new LessThanOrEqual <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.Or:
                we = new Or <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.Multiply:
                we = new Multiply <TLeft, TRight, TResult>()
                {
                    Checked = false,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.NotEqual:
                we = new NotEqual <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.OrElse:
                we = new OrElse()
                {
                    Left  = TestExpression.GetWorkflowElementFromExpectedNode <bool>(left),
                    Right = TestExpression.GetWorkflowElementFromExpectedNode <bool>(right)
                };
                break;

            case BinaryOperator.Subtract:
                we = new Subtract <TLeft, TRight, TResult>()
                {
                    Checked = false,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            default:
                throw new NotSupportedException(string.Format("Operator: {0} is unsupported", op.ToString()));
            }

            return(we);
        }