GetProperty() private static method

private static GetProperty ( MethodInfo mi, string paramName, int index = -1 ) : PropertyInfo
mi System.Reflection.MethodInfo
paramName string
index int
return System.Reflection.PropertyInfo
Ejemplo n.º 1
0
 /// <summary>
 /// Creates a <see cref="T:System.Linq.Expressions.MemberExpression"/> that represents accessing a property by using a property accessor method.
 /// </summary>
 ///
 /// <returns>
 /// A <see cref="T:System.Linq.Expressions.MemberExpression"/> that has the <see cref="P:System.Linq.Expressions.Expression.NodeType"/> property equal to <see cref="F:System.Linq.Expressions.ExpressionType.MemberAccess"/>, the <see cref="P:System.Linq.Expressions.MemberExpression.Expression"/> property set to <paramref name="expression"/> and the <see cref="P:System.Linq.Expressions.MemberExpression.Member"/> property set to the <see cref="T:System.Reflection.PropertyInfo"/> that represents the property accessed in <paramref name="propertyAccessor"/>.
 /// </returns>
 /// <param name="expression">An <see cref="T:System.Linq.Expressions.Expression"/> to set the <see cref="P:System.Linq.Expressions.MemberExpression.Expression"/> property equal to. This can be null for static properties.</param><param name="propertyAccessor">The <see cref="T:System.Reflection.MethodInfo"/> that represents a property accessor method.</param><exception cref="T:System.ArgumentNullException"><paramref name="propertyAccessor"/> is null.-or-The method that <paramref name="propertyAccessor"/> represents is not static (Shared in Visual Basic) and <paramref name="expression"/> is null.</exception><exception cref="T:System.ArgumentException"><paramref name="expression"/>.Type is not assignable to the declaring type of the method represented by <paramref name="propertyAccessor"/>.-or-The method that <paramref name="propertyAccessor"/> represents is not a property accessor method.</exception>
 public static MemberExpression Property(Expression expression, MethodInfo propertyAccessor)
 {
     return(Expression.Property(expression, Expression.GetProperty(propertyAccessor)));
 }