System.ComponentModel.ReflectPropertyDescriptor.ShouldSerializeValue C# (CSharp) Method

ShouldSerializeValue() public method

Indicates whether the value of this property needs to be persisted. In other words, it indicates whether the state of the property is distinct from when the component is first instantiated. If there is a default value specified in this ReflectPropertyDescriptor, it will be compared against the property's current value to determine this. If there is't, the ShouldSerializeXXX method is looked for and invoked if found. If both these routes fail, true will be returned. If this returns false, a tool should not persist this property's value.
public ShouldSerializeValue ( object component ) : bool
component object
return bool
        public override bool ShouldSerializeValue(object component)
        {
            component = GetInvocationTarget(_componentClass, component);

            if (IsReadOnly)
            {
                if (ShouldSerializeMethodValue != null)
                {
                    try
                    {
                        return (bool)ShouldSerializeMethodValue.Invoke(component, null);
                    }
                    catch { }
                }
                return Attributes.Contains(DesignerSerializationVisibilityAttribute.Content);
            }
            else if (DefaultValue == s_noValue)
            {
                if (ShouldSerializeMethodValue != null)
                {
                    try
                    {
                        return (bool)ShouldSerializeMethodValue.Invoke(component, null);
                    }
                    catch { }
                }
                return true;
            }
            return !object.Equals(DefaultValue, GetValue(component));
        }