private GetInvokee ( Type componentClass, object component ) : object | ||
componentClass | Type | |
component | object | |
return | object |
public override void SetValue(object component, object value) { DesignerTransaction tran = CreateTransaction(component, "Set Property '" + Name + "'"); object propertyHolder = MemberDescriptor.GetInvokee(_componentType, component); object old = GetValue(propertyHolder); try { GetPropertyInfo().SetValue(propertyHolder, value, null); EndTransaction(component, tran, old, value, true); } catch { EndTransaction(component, tran, old, value, false); throw; } }
public override bool CanResetValue(object component) { component = MemberDescriptor.GetInvokee(_componentType, component); DefaultValueAttribute attrib = ((DefaultValueAttribute)Attributes[typeof(DefaultValueAttribute)]); if (attrib != null) { object current = GetValue(component); if (attrib.Value == null || current == null) { if (attrib.Value != current) { return(true); } if (attrib.Value == null && current == null) { return(false); } } return(!attrib.Value.Equals(current)); } else { #if NET_2_0 if (!_member.CanWrite) { return(false); } #endif MethodInfo mi = FindPropertyMethod(component, "ShouldPersist"); if (mi != null) { return((bool)mi.Invoke(component, null)); } mi = FindPropertyMethod(component, "ShouldSerialize"); if (mi != null && !((bool)mi.Invoke(component, null))) { return(false); } mi = FindPropertyMethod(component, "Reset"); return(mi != null); } }
public override void SetValue(object component, object value) { System.ComponentModel.Design.DesignerTransaction tran = this.CreateTransaction(component, "Set Property '" + this.Name + "'"); object invokee = MemberDescriptor.GetInvokee(this._componentType, component); object value2 = this.GetValue(invokee); try { this.InitAccessors(); this.setter.SetValue(invokee, value, null); this.EndTransaction(component, tran, value2, value, true); } catch { this.EndTransaction(component, tran, value2, value, false); throw; } }
public override void SetValue(object component, object value) { DesignerTransaction tran = CreateTransaction(component, "Set Property '" + Name + "'"); object invokee = MemberDescriptor.GetInvokee(_componentType, component); object value2 = GetValue(invokee); try { InitAccessors(); setter.SetValue(invokee, value, null); EndTransaction(component, tran, value2, value, commit: true); } catch { EndTransaction(component, tran, value2, value, commit: false); throw; IL_0064 :; } }
public override bool CanResetValue(object component) { component = MemberDescriptor.GetInvokee(_componentType, component); DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)Attributes[typeof(DefaultValueAttribute)]; if (defaultValueAttribute != null) { object value = GetValue(component); if (defaultValueAttribute.Value == null || value == null) { if (defaultValueAttribute.Value != value) { return(true); } if (defaultValueAttribute.Value == null && value == null) { return(false); } } return(!defaultValueAttribute.Value.Equals(value)); } if (!_member.CanWrite) { return(false); } MethodInfo methodInfo = FindPropertyMethod(component, "ShouldPersist"); if (methodInfo != null) { return((bool)methodInfo.Invoke(component, null)); } methodInfo = FindPropertyMethod(component, "ShouldSerialize"); if (methodInfo != null && !(bool)methodInfo.Invoke(component, null)) { return(false); } methodInfo = FindPropertyMethod(component, "Reset"); return(methodInfo != null); }
public override bool ShouldSerializeValue(object component) { component = MemberDescriptor.GetInvokee(_componentType, component); if (IsReadOnly) { MethodInfo mi = FindPropertyMethod(component, "ShouldSerialize"); if (mi != null) { return((bool)mi.Invoke(component, null)); } return(Attributes.Contains(DesignerSerializationVisibilityAttribute.Content)); } DefaultValueAttribute attrib = ((DefaultValueAttribute)Attributes[typeof(DefaultValueAttribute)]); if (attrib != null) { object current = GetValue(component); if (attrib.Value == null || current == null) { return(attrib.Value != current); } return(!attrib.Value.Equals(current)); } else { MethodInfo mi = FindPropertyMethod(component, "ShouldSerialize"); if (mi != null) { return((bool)mi.Invoke(component, null)); } // MSDN: If this method cannot find a DefaultValueAttribute or a ShouldSerializeMyProperty method, // it cannot create optimizations and it returns true. return(true); } }
public override void ResetValue(object component) { object invokee = MemberDescriptor.GetInvokee(_componentType, component); DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)Attributes[typeof(DefaultValueAttribute)]; if (defaultValueAttribute != null) { SetValue(invokee, defaultValueAttribute.Value); } DesignerTransaction tran = CreateTransaction(component, "Reset Property '" + Name + "'"); object value = GetValue(invokee); try { FindPropertyMethod(invokee, "Reset")?.Invoke(invokee, null); EndTransaction(component, tran, value, GetValue(invokee), commit: true); } catch { EndTransaction(component, tran, value, GetValue(invokee), commit: false); throw; IL_00a9 :; } }
public override object GetValue(object component) { component = MemberDescriptor.GetInvokee(_componentType, component); InitAccessors(); return(getter.GetValue(component, null)); }
public override object GetValue(object component) { component = MemberDescriptor.GetInvokee(_componentType, component); return(GetPropertyInfo().GetValue(component, null)); }