How can I get the PropertyDescriptor
for the current property? For example:
[MyAttribute("SomeText")]
public string MyProperty
{
get{....}
set
{
// here I want to get PropertyDescriptor for this property.
}
}
To access the property descriptor of property, we need to use a static method provided by the Object. The Object. getOwnPropertyDescriptor method returns the property descriptor of the prop which is the property name on the obj object. Object.
PropertyDescriptors allows the manipulation of a model's properties (also called parameters) via gui widgets displayed on the parameter's tab pane. You can also use PropertyDescriptors in conjunction with an agent's parameters. More on that at the end of this document.
A PropertyDescriptor describes a property on an Object . Any JavaScript object can be used as a PropertyDescriptor where unspecified properties will be treated as undefined or false .
You could try this:
public string Test
{
get
{
//Get properties for this
System.ComponentModel.PropertyDescriptorCollection pdc = System.ComponentModel.TypeDescriptor.GetProperties( this );
//Get property descriptor for current property
System.ComponentModel.PropertyDescriptor pd = pdc[ System.Reflection.MethodBase.GetCurrentMethod().Name ];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With