public static MemberInfo Member(Expression exp) { MemberInfo prop = null; var visitor = new ExpressionVisitorV { VisitMember = e => { prop = e.Member; }, }; visitor.VisitUnary = e => visitor.Visit(e.Operand); visitor.Visit(exp); return(prop); }
public static string MemberName(Expression exp) { string r = null; var visitor = new ExpressionVisitorV { VisitMember = e => { r = e.Member.Name; }, VisitMethodCall = e => { r = e.Method.Name; }, }; visitor.VisitUnary = e => visitor.Visit(e.Operand); visitor.Visit(exp); return(r); }