Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private static object GetPropertyValue(object @object, PropertyInfo propertyInfo, Type objectType)
        {
            PropertyAccessItem propertyAccessItem = GetPropertyAccessItem(objectType, propertyInfo);

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

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