예제 #1
0
        public static object GetFieldValue(object obj, FieldInfo field)
        {
            //创建Set委托
            var getter = DynamicMethodCompilerUtil.CreateGetHandler(obj.GetType(), field);

            //获取字段值
            return(getter(obj));
        }
예제 #2
0
        public static object GetPropertyValue(object obj, PropertyInfo property)
        {
            //创建Set委托
            var getter = DynamicMethodCompilerUtil.CreateGetHandler(obj.GetType(), property);

            //获取属性值
            return(getter(obj));
        }