Using System.Reflection to obtain parameter values dynamically

AWS

Staff member
Jan 10, 2007
Florida
I'm trying to come up with some code that I can use to add INFO level tracing to my DAL and BL code.* So far, I'm able to obtain plenty of metadata about the functions, but not the actual parameter values:

StringBuilder sb = newStringBuilder()
sb.Append(System.Reflection.
MethodBase.GetCurrentMethod())
ParameterInfo [] ParameterInfos = System.Reflection.MethodBase.GetCurrentMethod().GetParameters()
foreach (ParameterInfo ParameterInfo in ParameterInfos)
sb.Append(
" ").Append(ParameterInfo.Name).Append(" {").Append(ParameterInfo).Append("}")
TraceLog.Info(sb.ToString())



this will output the metadata about the parameters, but not the actual values.* For example, it will show me that the value is an Int32, but not that the value is 3.

I know that this is doable, but I can't seem to pick the right combination of words, punctuation, and secret masonic dances required to get Google to return a clue.

Any clues?

Edit: oh, and what the heck is the 'code' tag on C9 again?


More...

View All Our Microsft Related Feeds
 
Back
Top Bottom