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

ShouldSerializeValue() public abstract method

When overridden in a derived class, indicates whether the value of this property needs to be persisted.

public abstract ShouldSerializeValue ( object component ) : bool
component object
return bool
        public abstract bool ShouldSerializeValue(object component);

Usage Example

 private object GetPropertyValue(IDesignerSerializationManager manager, PropertyDescriptor property, object value, out bool validValue)
 {
     object obj2 = null;
     validValue = true;
     try
     {
         if (!property.ShouldSerializeValue(value))
         {
             AmbientValueAttribute attribute = (AmbientValueAttribute) property.Attributes[typeof(AmbientValueAttribute)];
             if (attribute != null)
             {
                 return attribute.Value;
             }
             DefaultValueAttribute attribute2 = (DefaultValueAttribute) property.Attributes[typeof(DefaultValueAttribute)];
             if (attribute2 != null)
             {
                 return attribute2.Value;
             }
             validValue = false;
         }
         obj2 = property.GetValue(value);
     }
     catch (Exception exception)
     {
         validValue = false;
         manager.ReportError(System.Design.SR.GetString("SerializerPropertyGenFailed", new object[] { property.Name, exception.Message }));
     }
     return obj2;
 }
All Usage Examples Of System.ComponentModel.PropertyDescriptor::ShouldSerializeValue