核心递归方法 根据表达式类型 跳转到 具体的处理方法 处理完后 返回 null 跳出循环
/// <summary> /// 访问 /// </summary> /// <param name="node">节点</param> /// <returns></returns> public Expression Visit(Expression node) { //Console.WriteLine($"当前访问 {node.NodeType} 类型表达式"); switch (node) { case LambdaExpression: { return Visit(VisitLambda(node as LambdaExpression)); }; case UnaryExpression: { return Visit(VisitUnary(node as UnaryExpression)); } case BinaryExpression: { return Visit(VisitBinary(node as BinaryExpression)); } case MethodCallExpression: { return Visit(VisitMethodCall(node as MethodCallExpression)); } case ConditionalExpression: { return Visit(VisitConditional(node as ConditionalExpression)); } case NewExpression: { return Visit(VisitNew(node as NewExpression)); } case MemberInitExpression: { return Visit(VisitMemberInit(node as MemberInitExpression)); } case NewArrayExpression: { return Visit(VisitNewArray(node as NewArrayExpression)); } case ListInitExpression: { return Visit(VisitListInit(node as ListInitExpression)); } case MemberExpression: { return Visit(VisitMember(node as MemberExpression)); } case ConstantExpression: { return Visit(VisitConstant(node as ConstantExpression)); } default: return null; } }
搜索
复制
标签:node,ExpressionVisitor,正序,递归,Visit,case,return,抽象类,表达式 From: https://www.cnblogs.com/China-Mr-zhong/p/16858535.html