GuOrg/Gu.State

Use Expression.Lambda

Closed this issue · 1 comments

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();
    }
}

Done.