Exemplo n.º 1
0
 internal FullBinaryExpressionSlim(ExpressionType nodeType, ExpressionSlim left, ExpressionSlim right, bool liftToNull, MethodInfoSlim method, LambdaExpressionSlim conversion)
     : base(nodeType, left, right)
 {
     IsLiftedToNull = liftToNull;
     Method         = method;
     Conversion     = conversion;
 }
Exemplo 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));
        }
 /// <summary>
 /// Visits a lambda expression slim tree node, produces a lambda expression.
 /// </summary>
 /// <param name="node">Node to visit.</param>
 /// <param name="body">Lambda body expression.</param>
 /// <param name="parameters">Lambda parameter expressions.</param>
 /// <returns>The lambda expression represented by the expression slim node.</returns>
 protected override LambdaExpression MakeLambda(LambdaExpressionSlim node, Expression body, ReadOnlyCollection <ParameterExpression> parameters)
 {
     if (node.DelegateType != null)
     {
         var delegateType = MakeType(node.DelegateType);
         return(_factory.Lambda(delegateType, body, parameters));
     }
     else
     {
         return(_factory.Lambda(body, parameters));
     }
 }
Exemplo n.º 4
0
        protected internal override ExpressionSlim VisitLambda(LambdaExpressionSlim node)
        {
            // CONSIDER: Historically, this has omitted the delegate type. We can consider to add it later.

            Append("Lambda(");
            Visit(node.Body);
            if (node.Parameters.Count > 0)
            {
                Append(", ");
                Visit(", ", node.Parameters);
            }
            Append(')');

            return(node);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Visits a lambda expression tree node.
 /// </summary>
 /// <param name="node">Node to visit.</param>
 /// <returns>Result of visiting the node.</returns>
 protected internal virtual ExpressionSlim VisitLambda(LambdaExpressionSlim node)
 {
     return(node.Update(Visit(node.Body), VisitAndConvert(node.Parameters)));
 }
Exemplo n.º 6
0
#pragma warning restore CA1062
#pragma warning restore IDE0079

        internal static BinaryExpressionSlim Make(ExpressionType nodeType, ExpressionSlim left, ExpressionSlim right, bool liftToNull, MethodInfoSlim method, LambdaExpressionSlim conversion)
        {
            if (conversion == null)
            {
                if (liftToNull)
                {
                    if (method == null)
                    {
                        return(new LiftedBinaryExpressionSlim(nodeType, left, right));
                    }
                    else
                    {
                        return(new MethodBasedLiftedBinaryExpressionSlim(nodeType, left, right, method));
                    }
                }
                else
                {
                    if (method == null)
                    {
                        return(new NonLiftedBinaryExpressionSlim(nodeType, left, right));
                    }
                    else
                    {
                        return(new MethodBasedNonLiftedBinaryExpressionSlim(nodeType, left, right, method));
                    }
                }
            }

            return(new FullBinaryExpressionSlim(nodeType, left, right, liftToNull, method, conversion));
        }