public static object GetFieldValue(object obj, FieldInfo field) { //创建Set委托 var getter = DynamicMethodCompilerUtil.CreateGetHandler(obj.GetType(), field); //获取字段值 return(getter(obj)); }
public static object GetPropertyValue(object obj, PropertyInfo property) { //创建Set委托 var getter = DynamicMethodCompilerUtil.CreateGetHandler(obj.GetType(), property); //获取属性值 return(getter(obj)); }