PropertyDescriptor.GetValue and PropertyInfo.GetValue
-
PropertyDescriptor.GetValue(object component); what is this component. I do not get. Can someone please get an example. Also why PropertyInfo.GetValue(object, objects[]) needs to have parameters. Why we cannot have values through reflection directly. Can someone give me example of propertydescriptor.GetValue(object component), how to use it. I do not find much on msdn.
-
PropertyDescriptor.GetValue(object component); what is this component. I do not get. Can someone please get an example. Also why PropertyInfo.GetValue(object, objects[]) needs to have parameters. Why we cannot have values through reflection directly. Can someone give me example of propertydescriptor.GetValue(object component), how to use it. I do not find much on msdn.
The component is the object instance to fetch from. To fetch the value you must have an acutal instance and the method must have a reference to it. I usually refer to it as the "context" but MS has called it the component here.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
PropertyDescriptor.GetValue(object component); what is this component. I do not get. Can someone please get an example. Also why PropertyInfo.GetValue(object, objects[]) needs to have parameters. Why we cannot have values through reflection directly. Can someone give me example of propertydescriptor.GetValue(object component), how to use it. I do not find much on msdn.
kashme wrote:
what is this component
It's an abstract description of a property[^].
kashme wrote:
Can someone please get an example
At the bottom of that page are the usual examples. Used it for example, when implementing a
GetProperties
[^] method. A neat way to provide properties that aPropertyEditor
can understand while passing an array wrapped in a ICustomTypeDescriptor[^].Bastard Programmer from Hell :suss: