I have the following Auto Property
[DefaultValue(true)]
public bool RetrieveAllInfo { get; set; }
when I try to use it inside the code i f
One hack for this is on this link.
In short, call this function at the end of constructor.
static public void ApplyDefaultValues(object self)
{
foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(self)) {
DefaultValueAttribute attr = prop.Attributes[typeof(DefaultValueAttribute)] as DefaultValueAttribute;
if (attr == null) continue;
prop.SetValue(self, attr.Value);
}
}