/// <summary> /// Creates a new instance of the safe property wrapper. /// </summary> /// <param name="propertyInfo">Property to wrap.</param> public SafeProperty(PropertyInfo propertyInfo) { Guard.ArgumentNotNull(propertyInfo, "propertyInfo", "You cannot create a dynamic property for a null value."); this.propertyInfo = propertyInfo; getter = DynamicReflectionManager.CreatePropertyGetter(propertyInfo); setter = DynamicReflectionManager.CreatePropertySetter(propertyInfo); }
public AssignmentEntry(string name, AssignmentMember @from, AssignmentMember to) { Name = name; From = @from; To = to; GetValueFn = From.GetGetValueFn(); SetValueFn = To.GetSetValueFn(); }
/// <summary> /// Creates a new instance of the safe property wrapper. /// </summary> /// <param name="propertyInfo">Property to wrap.</param> public SafeProperty(PropertyInfo propertyInfo) { AssertUtils.ArgumentNotNull(propertyInfo, "You cannot create a dynamic property for a null value."); _propertyInfo = propertyInfo; var pi = GetOrCreateDynamicProperty(propertyInfo); _getter = pi.Getter; _setter = pi.Setter; }
/// <summary> /// Creates a new instance of the safe property wrapper. /// </summary> /// <param name="propertyInfo">Property to wrap.</param> public SafeProperty(PropertyInfo propertyInfo) { AssertUtils.ArgumentNotNull(propertyInfo, "You cannot create a dynamic property for a null value."); this.propertyInfo = propertyInfo; DynamicPropertyCacheEntry pi = GetOrCreateDynamicProperty(propertyInfo); getter = pi.Getter; setter = pi.Setter; }
public AssignmentEntry(string name, AssignmentMember @from, AssignmentMember to) { Name = name; From = @from; To = to; GetValueFn = From.GetGetValueFn(); SetValueFn = To.GetSetValueFn(); ConvertValueFn = TypeConverter.CreateTypeConverter(From.Type, To.Type); }
static AttributeKeyBinder() { //todo: replace with function to get and set pk values in repository var pk = typeof(TEntity).GetProperties(BindingFlags.Instance | BindingFlags.Public) .FirstOrDefault(m => m.GetCustomAttributes(true).Any(n => n is KeyAttribute)); if (pk == null) { throw new InvalidOperationException( $"Unable to resolve the primary key field of entity {typeof(TEntity).Name} to build its getter and setter functions."); } GetterFn = pk.GetPropertyGetterFn(); SetterFn = pk.GetPropertySetterFn(); }
public PropertyEditorParams(Widget inspectorPane, List <object> objects, Type type, string propertyName) { InspectorPane = inspectorPane; Objects = objects; Type = type; PropertyName = propertyName; TangerineAttribute = PropertyAttributes <TangerineKeyframeColorAttribute> .Get(Type, PropertyName) ?? new TangerineKeyframeColorAttribute(0); Group = PropertyAttributes <TangerineGroupAttribute> .Get(Type, PropertyName)?.Name ?? String.Empty; PropertyInfo = Type.GetProperty(PropertyName); PropertySetter = SetProperty; NumericEditBoxFactory = () => new ThemedNumericEditBox(); DropDownListFactory = () => new ThemedDropDownList(); EditBoxFactory = () => new ThemedEditBox(); }
public static StructPropertySetter <TReflected, TProperty> Create(PropertyInfo property) { if (property == null) { throw new ArgumentNullException("property"); } if (typeof(TReflected) != property.DeclaringType) { throw new ArgumentException("The property's ReflectedType must exactly match TReflected.", "property"); } if (typeof(TProperty) != property.PropertyType) { throw new ArgumentException("The property's PropertyType must exactly match TProperty.", "property"); } if (!property.CanWrite) { throw new ArgumentException("The property must be writable.", "property"); } if (property.GetIndexParameters().Length != 0) { throw new ArgumentException("The property must not have index parameters.", "property"); } MethodInfo setMethod = property.SetMethod; Debug.Assert(setMethod != null); if (setMethod.IsStatic) { throw new ArgumentException("The property must not be static.", "property"); } Debug.Assert(setMethod.ReflectedType == typeof(TReflected)); Debug.Assert(setMethod.ReflectedType.IsValueType); Debug.Assert(setMethod.GetParameters().Length == 1); Debug.Assert(setMethod.GetParameters()[0].ParameterType == typeof(TProperty)); Debug.Assert(setMethod.ReturnType == typeof(void)); PropertySetterDelegate setter = (PropertySetterDelegate)setMethod.CreateDelegate(typeof(PropertySetterDelegate)); return(new StructPropertySetter <TReflected, TProperty>(setter)); }
public DynamicPropertyCacheEntry(PropertyGetterDelegate getter, PropertySetterDelegate setter) { Getter = getter; Setter = setter; }
/// <summary> /// Creates a new instance of the safe property wrapper. /// </summary> /// <param name="propertyInfo">Property to wrap.</param> public SafeProperty(PropertyInfo propertyInfo) { this.propertyInfo = propertyInfo; getter = DynamicReflectionManager.CreatePropertyGetter(propertyInfo); setter = DynamicReflectionManager.CreatePropertySetter(propertyInfo); }
public PropertyCacheEntry(Type type, PropertyGetterDelegate getter, PropertySetterDelegate setter) { PropertyType = type; Getter = getter; Setter = setter; }
private StructPropertySetter(PropertySetterDelegate setter) { Debug.Assert(setter != null); _setter = setter; }