/// <summary>
        /// Visits a binary expression slim tree node, produces a binary expression.
        /// </summary>
        /// <param name="node">Node to visit.</param>
        /// <param name="left">Left operand.</param>
        /// <param name="conversion">Conversion operand.</param>
        /// <param name="right">Right operand.</param>
        /// <returns>The binary expression represented by the expression slim node.</returns>
        protected override Expression MakeBinary(BinaryExpressionSlim node, Expression left, LambdaExpression conversion, Expression right)
        {
            var method = VisitIfNotNull(node.Method, MakeMethodCachedDelegate);

            var res = default(Expression);

            if (method == null && conversion == null && !left.Type.IsValueType && !right.Type.IsValueType)
            {
                switch (node.NodeType)
                {
                case ExpressionType.Equal:
                    res = _factory.ReferenceEqual(left, right);
                    break;

                case ExpressionType.NotEqual:
                    res = _factory.ReferenceNotEqual(left, right);
                    break;
                }
            }

            if (res == null)
            {
                res = _factory.MakeBinary(node.NodeType, left, right, node.IsLiftedToNull, method, conversion);
            }

            return(res);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="left">The <see cref="Left"/> child node of the result.</param>
        /// <param name="conversion">The <see cref="Conversion"/> child node of the result.</param>
        /// <param name="right">The <see cref="Right"/> child node of the result.</param>
        /// <returns>This expression if no children are changed or an expression with the updated children.</returns>
        public BinaryExpressionSlim Update(ExpressionSlim left, LambdaExpressionSlim conversion, ExpressionSlim right)
        {
            if (left == Left && right == Right && conversion == Conversion)
            {
                return(this);
            }

            return(BinaryExpressionSlim.Make(NodeType, left, right, IsLiftedToNull, Method, conversion));
        }
Esempio n. 3
0
        protected internal override ExpressionSlim VisitBinary(BinaryExpressionSlim node)
        {
            // CONSIDER: Conversion has been historically omitted here. We can consider adding it later.
            // CONSIDER: Method has been historically omitted here. We can consider adding it later.

            Append(node.NodeType);
            Append('(');
            Visit(node.Left);
            Append(", ");
            Visit(node.Right);
            Append(')');

            return(node);
        }
 /// <summary>
 /// Visits a binary expression tree node.
 /// </summary>
 /// <param name="node">Node to visit.</param>
 /// <returns>Result of visiting the node.</returns>
 protected internal virtual ExpressionSlim VisitBinary(BinaryExpressionSlim node)
 {
     return(node.Update(Visit(node.Left), VisitAndConvert(node.Conversion), Visit(node.Right)));
 }