Closed furesoft closed 1 year ago
private PropertyDescriptorCollection GetProperties(object target)
{
if(target is ICustomTypeDescriptor ctd)
{
return ctd.GetProperties();
}
return TypeDescriptor.GetProperties(target);
}
The TypeDescriptor.GetProperties method is used internally to get properties, so TypeDescriptionProvider is natively supported. I have added a TypeDescriptionProvider use case in the latest version of the CustomObject example for reference.
public class TestCustomObject
{
public string First { get; set; } = "";
public string Second { get; set; } = "";
[Browsable(false)]
public string[] StringArray { get; set; } = new string[3] { "ABC", "DEF", "HJK" };
}
Add support for TypeDescriptionProvider for encapsulation and make the classes that uses a custom typedescriptor smaller.