GuOrg / Gu.State

MIT License
9 stars 3 forks source link

Use Expression.Lambda #67

Closed JohanLarsson closed 5 years ago

JohanLarsson commented 6 years ago
internal static class PropertyInfoExt
{
    internal static Func<TSource, TValue> CreateGetter<TSource, TValue>(this PropertyInfo property)
    {
        var parameter = Expression.Parameter(typeof(TSource));
        return Expression.Lambda<Func<TSource, TValue>>(Expression.Property(parameter, property), parameter)
                         .Compile();
    }
}
JohanLarsson commented 5 years ago

Done.