I need to add an attribute to some property in runtime (for design-time purposes). I know I can do this for classes:
TypeDescriptor.AddAttributes(typeof(MyType), new MyRuntimeAttribute());
But I can't find any way to do the same for properties.
Any suggestions?
UPD: The exactly task is following:
public class BaseClass {
public BaseClass(string name) { Name = name; }
public Name { get; set; }
}
public class Descendant1: BaseClass {
public Descendant1() : base("Default Name 1") { }
}
...
public class DescendantN: BaseClass {
public DescendantN() : base("Default Name N") { }
}
I want each of the descendants to have each own DefaultValueAttribute at the Name property with the corresponding default name. And I don't want to hardcode DefaultValueAttribute on each descentand :)