O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Property Accessor Delegates

When the PropertyInfo instance has been obtained, it is used to create a delegate for the get and set accessors. For this the Delegate.CreateDelegate method is used, via a custom PropertyInfo extension method called CreateGetter, in the PropertyUtility class. Within the CreateGetter method, the type argument, required by the Delegate.CreateDelegate method, is generated using the Expression.GetFuncType method. If the property is of type string, for example, a type representing a Func<string> is produced. See the following excerpt:

public static Func<TProperty> CreateGetter<TProperty>(    this PropertyInfo propertyInfo, object owner){    ArgumentValidator.AssertNotNull(propertyInfo, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required