internal PropertyDescriptor GetDefaultProperty(object instance)
{
AttributeCollection attributes;
if (instance != null)
{
attributes = TypeDescriptor.GetAttributes(instance);
}
else
{
attributes = TypeDescriptor.GetAttributes(_type);
}
DefaultPropertyAttribute attr = (DefaultPropertyAttribute)attributes[typeof(DefaultPropertyAttribute)];
if (attr != null && attr.Name != null)
{
if (instance != null)
{
return TypeDescriptor.GetProperties(instance)[attr.Name];
}
else
{
return TypeDescriptor.GetProperties(_type)[attr.Name];
}
}
return null;
}