We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public static class ReflectionUtils { public static Func<object, object> GenerateGetterExpr(PropertyInfo property) { var objInstanceExpr = Expression.Parameter(typeof(object), "instance"); var typedInstanceExpr = Expression.TypeAs(objInstanceExpr, property.DeclaringType); var propertyExpr = Expression.Property(typedInstanceExpr, property); var propertyObjExpr = Expression.Convert(propertyExpr, typeof(object)); return Expression.Lambda<Func<object, object>>(propertyObjExpr, objInstanceExpr).Compile(); } public static Func<object, object> GenerateGetterFunc(PropertyInfo property) { var objInstanceExpr = Expression.Parameter(typeof(object), "instance"); var typedInstanceExpr = Expression.TypeAs(objInstanceExpr, property.DeclaringType); var propertyExpr = Expression.Property(typedInstanceExpr, property); var propertyObjExpr = Expression.Convert(propertyExpr, typeof(object)); return Expression.Lambda<Func<object, object>>(propertyObjExpr, objInstanceExpr).Compile(); } ```
The text was updated successfully, but these errors were encountered:
Sounds like indeed this is a duplicate. Do you want to contribute a PR and remove one of the methods?
Sorry, something went wrong.
Closed via #304
No branches or pull requests
The text was updated successfully, but these errors were encountered: