Is there a way to use ParameterInfo and PropertyInfo interchangeably?

For me, these are very similar structures. I was hoping there was a way to easily transform or transform one into the other.

I use reflection to make magic. I took the path of using parameterized constructors to create some user-selected objects that they populate with parameter values ​​using the UI.

The problem is one of the objects being accepted in the structure as a parameter and I cannot get the properties of the structures as parameter information as property properties.

But I don't want to just reproduce the parameter info code I have for the property info. It would be nice if I could pass property information as parameter information. Everything is really the same, except for a few property names; ParameterType as opposed to PropertyType and what not.

I might have to do my own conversion, or write my own class that stores the properties I need and just use that custom object. Greetings.

+2


source to share


1 answer


No no.

These two classes represent two completely different concepts.



A property is a type attribute. The PropertyInfo class will allow you to set or get a value and give you additional information about that property.

A parameter is an attribute of the method signature (an accessor on a type can also have a parameter). The ParameterInfo class represents this concept and can tell you the type of the parameter, the position in the method signature, whether it is an out or ref parameter, etc. See MSDN doc . The Info parameter is not directly related to the type.

+2


source







All Articles