Unwinding a Property Lambda Expression

Resolving a property’s name and creating delegates for its get and set property accessors involves unwinding of the Lambda expression and retrieving the PropertyInfo instance. In the sample code, this is done using the custom PropertyUtility.GetPropertyInfo method, which retrieves the PropertyInfo instance from the expression’s Member property, as shown:

public static PropertyInfo GetPropertyInfo<T>(Expression<Func<T>> expression){    var memberExpression = expression.Body as MemberExpression;    if (memberExpression == null)    {        throw new ArgumentException(            "MemberExpression expected.", "expression");    }    if (memberExpression.Member == null)    {         ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.