public static IEnumerable <MemberExpression> ExtractMembers(Expression expr) { var visitor = new MemberExtractor(); visitor.Visit(expr); return(visitor._members); }
public static MemberExpression ExtractSingleMember(Expression expr) { var visitor = new MemberExtractor(); visitor.Visit(expr); if (visitor._members.Count == 0) { throw new ArgumentNullException(nameof(expr), "No MemberExpression nodes found"); } if (visitor._members.Count > 1) { throw new InvalidOperationException("More than 1 MemberExpression nodes found"); } return(visitor._members.First()); }