public Update ( Expression expression ) : MemberExpression | ||
expression | Expression | The |
Résultat | MemberExpression |
/// <summary> /// Visits the children of the <see cref="MemberExpression" />. /// </summary> /// <param name="node">The expression to visit.</param> /// <returns> /// The modified expression, if it or any subexpression was modified; /// otherwise, returns the original expression. /// </returns> protected internal virtual Expression VisitMember(MemberExpression node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } return(node.Update(Visit(node.Expression))); }
protected override Expression VisitMember(MemberExpression memberExpression) { var newExpression = Visit(memberExpression.Expression); var subQueryExpression = newExpression as SubQueryExpression; var subSelector = subQueryExpression?.QueryModel.SelectClause.Selector; if (subSelector is QuerySourceReferenceExpression || subSelector is SubQueryExpression) { var subQueryModel = subQueryExpression.QueryModel; subQueryModel.SelectClause.Selector = VisitMember(memberExpression.Update(subSelector)); subQueryModel.ResultTypeOverride = subQueryModel.SelectClause.Selector.Type; return new SubQueryExpression(subQueryModel); } return memberExpression.Update(newExpression); }
protected override Expression VisitMember(MemberExpression m) { Expression source = this.Visit(m.Expression); switch (source.NodeType) { case ExpressionType.Call: MethodCallExpression call = (MethodCallExpression)source; if (call != null && call.Method.Name == "NewDefaultProjectedObject") { var bindings = ((ConstantExpression)call.Arguments[0]).Value as ReadOnlyCollection<MemberBinding>; for (int i = 0, n = bindings.Count; i < n; i++) { MemberAssignment assign = bindings[i] as MemberAssignment; if (assign != null && MembersMatch(assign.Member, m.Member)) { return assign.Expression; } } } break; case ExpressionType.MemberInit: MemberInitExpression min = (MemberInitExpression)source; for (int i = 0, n = min.Bindings.Count; i < n; i++) { MemberAssignment assign = min.Bindings[i] as MemberAssignment; if (assign != null && MembersMatch(assign.Member, m.Member)) { return assign.Expression; } } break; case ExpressionType.New: NewExpression nex = (NewExpression)source; if (nex.Members != null) { for (int i = 0, n = nex.Members.Count; i < n; i++) { if (MembersMatch(nex.Members[i], m.Member)) { return nex.Arguments[i]; } } } break; } return m.Update(source); }
protected override ExpressionTree VisitMember(MemberExpression node) { MemberExpression expression; if (node.Expression != null) { CheckChildrenCount(1); var e = ExtractChildExpression(0); expression = node.Update(e); } else { CheckChildrenCount(0); expression = node; } return(CreateExpressionTree(expression)); }
/// <summary> /// Visits the children of the <see cref="MemberExpression"/>. /// </summary> /// <param name="node">The expression to visit.</param> /// <returns>The modified expression, if it or any subexpression was modified; /// otherwise, returns the original expression.</returns> protected internal virtual Expression VisitMember(MemberExpression node) { return(node.Update(Visit(node.Expression))); }
/// <summary> /// Visits a member expression with the specified <paramref name="isLval"/> behavior. /// See <see cref="VisitMember(MemberExpression)"/> for more information about visitor behavior. /// </summary> /// <param name="node">The member expression to visit.</param> /// <param name="isLval">Indicates whether the member expression occurs in an assignment target position.</param> /// <returns>The result of visiting the member expression.</returns> protected virtual Expression VisitMember(MemberExpression node, bool isLval) { var expression = isLval ? VisitLval(node.Expression) : Visit(node.Expression); return(node.Update(expression)); }