GetValue/SetValue with Public Properties using Reflection on a class
Posted on 2011-09-21
I have a class: clsProp_ProjectStructure.subCls_ProjectStructureDataSourceLink. This class has the following Public Properties:
Each of the properties has "_p" followed vy a letter then the actual variable.
s is for String
i is for Integer
b is for Boolean
I want to store the value of the Public Property in a DataTable. This table has three columns; PropertyName, PropertyVariable, and PropertyValue. I store the DataTable in a DataSet called dsDataSet. The DataTable is called Properties with the three columns just mentioned. I have gotten both the PropertyName and PropertyVariable, but am having issues getting the PropertyValue with GetValue.
I know that I use reflection to browse the properties. I also know. That Type is used as well. My issue is the proper coding in VB to get the value of the Public Property. GetProperties allows me to get multiple pieces of info on each Property, but I can't seam to figure out how to return the value. I would also like to use SetValue.
Could you show me an exqmple using the following asumptions:
1. The DataSet I am building is generated from one call to a class: clsDataSourceLinkBuilder_DataSet
2. The DataSet name is: dsDataSet
3. The TableName is: Properties
4. Each propooperty is as shown above
5. The class loops through the properties
6. pType would be the Class/Form/Control, etc. Iten that contains the properties I want to review.
7. pValue would be the object I am returning that holds the value
8. pInfo would be the PropertyInfo I am defining
pValue = PropertyInfo() = GetType()