User2000013726 posted
Hi, I was wondering if Reflection can be used for something like the following...
I am opening a table and reading through the "Name" column. The name column represents the name of a Global Variable inside my Shared_Routines module located in my App_Code folder of my ASP.NET web application.
TableName: Settings
Column: Name (name of the Global Variable)
Column: Value (value of the Global Variable)
WebSite
|- App_Code
|- Shared_Routines.vb
|- Public Module Shared_Routines
|- Global Variables...
Public
Module Shared_Routines
Public GlobalVar1 As Boolean = True
Public GlobalVar2 As String = "test"
Public GlobalVar3 As Long = 1234
...
Inside my Global.asax I connect to the database and iterate through a table containing a list of these three Global Variables (i.e. GlobalVar1, GlobalVar2, GlobalVar3) and want to dynamically store the values
of these Global Variables into the "Value" field of the same table.
I could use a SELECT CASE statement to obtain the values of the Global Variables by hard-coding all of the Global Variable names inside the SELECT CASE, but it would be simpler and more dynamic coding to use Reflection in some way to say...
DataSet("Value") = <some reflection to find the global variable with the same name as DataSet("Name")>
I have more than 3 Global Variables and I am not concerned if Reflection provides slower performance than a potentially gigantic SELECT CASE statement.
Any ideas?
Thanks!