模拟实现,性能还不错,比DynamicInvoke性能好的多。
中间加了一次Convert,可以实现任何对象的属性的调用,也就是EvalEx.GetEval<Func<object, object>>方式
public static class EvalEx
{
public static T GetEval<T>(Type type, string propertyPath)
{
if (type == null)
return default(T);
var func = DynamicExpression.ParseLambda(type, null, propertyPath);
var objParameter = System.Linq.Expressions.Expression.Parameter(typeof(object), "obj");
&n