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); }
private static object GetPropertyValue(object @object, PropertyInfo propertyInfo, Type objectType) { PropertyAccessItem propertyAccessItem = GetPropertyAccessItem(objectType, propertyInfo); return(propertyAccessItem.Getter.Invoke(@object)); }
public static void SetPropertyValue(object @object, Type objectType, PropertyInfo propertyInfo, object value) { PropertyAccessItem propertyAccessItem = GetPropertyAccessItem(objectType, propertyInfo); propertyAccessItem.Setter.Invoke(@object, value); }