?
Solved

GetValue/SetValue with Public Properties using Reflection on a class

Posted on 2011-09-21
2
Medium Priority
?
296 Views
Last Modified: 2012-05-12
Experts,

I have a class: clsProp_ProjectStructure.subCls_ProjectStructureDataSourceLink.  This class has the following Public Properties:

StrVarDataSourceLink.p_sDateAdded
StrVarDataSourceLink.p_sDateModified
StrVarDataSourceLink.p_iCodeSequence
StrVarDataSourceLink.p_sRecordStatus
StrVarDataSourceLink.p_sDataSourceName
StrVarDataSourceLink.p_iDatabaseType
StrVarDataSourceLink.p_bLockProperties
StrVarDataSourceLink.p_sConnectionMethod
StrVarDataSourceLink.p_sConnectionType
StrVarDataSourceLink.p_sServerName
StrVarDataSourceLink.p_sServerInstance
StrVarDataSourceLink.p_sDatabaseFolder
StrVarDataSourceLink.p_sDatabaseName
StrVarDataSourceLink.p_sTableName

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()
0
Comment
Question by:Peter Allen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 36577902
You should be able to use LINQ to DataSet extensions, to write a LINQ query to convert a generics list of that class into a DataTable.
0
 
LVL 18

Accepted Solution

by:
dj_alik earned 1000 total points
ID: 36578210
Convert Generic List In To DataTable
http://amitpatriwala.wordpress.com/2008/12/03/convert-generic-list-in-to-datatable/

Casting from a Collection to a Data Table using Generics and Attributes
http://www.codeproject.com/KB/cs/coreweb01.aspx

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question