示例#1
0
        private static PropertyAccessItem CreatePropertyAccessItem(Type objectType, PropertyInfo propertyInfo)
        {
            PropertyAccessItem propertyAccessItem = new PropertyAccessItem();

            if (propertyInfo.CanRead)
            {
                propertyAccessItem.Getter = DynamicMethodCompiler.CreateGetHandler(objectType, propertyInfo);
            }
            if (propertyInfo.CanWrite)
            {
                propertyAccessItem.Setter = DynamicMethodCompiler.CreateSetHandler(objectType, propertyInfo);
            }
            return(propertyAccessItem);
        }
示例#2
0
        private static object GetPropertyValue(object @object, PropertyInfo propertyInfo, Type objectType)
        {
            PropertyAccessItem propertyAccessItem = GetPropertyAccessItem(objectType, propertyInfo);

            return(propertyAccessItem.Getter.Invoke(@object));
        }
示例#3
0
        public static void SetPropertyValue(object @object, Type objectType, PropertyInfo propertyInfo, object value)
        {
            PropertyAccessItem propertyAccessItem = GetPropertyAccessItem(objectType, propertyInfo);

            propertyAccessItem.Setter.Invoke(@object, value);
        }