示例#1
0
        public static PropertyInfo GetPropertyInfo <T>(
            this Expression <Func <T, object> > expression)
        {
            MemberExpression memberExpression = GeneralExtensions.RemoveUnary(expression.Body);

            if (memberExpression == null)
            {
                return((PropertyInfo)null);
            }
            if (memberExpression.Member is PropertyInfo)
            {
                return(memberExpression.Member as PropertyInfo);
            }
            throw new ArgumentException("Cannot pass null to GetPropertyInfo");
        }
示例#2
0
 public static MemberInfo GetMember(this LambdaExpression expression)
 {
     return(GeneralExtensions.RemoveUnary(expression.Body)?.Member);
 }