question
I am writing some code, which should be able to get value The criteria for the method used in the class. I know how to get all the methods for the ParameterInfo [] array, but I do not know how to get the values. Is this also possible?
If so, then I think it is something to use the MethodBody property from the MethodInfo object, which allows you to inspect the IL stream including the properties, but I know that this How to do it, and I have not received the code applied to Google.
Code
// Finds the calling method from that class, which is called some class {public static zero FindMethod () for this (in the category of int i = 1; i & lt; framecount; i ++) {var frame = new stackframe (i); var methodInfo = frame.GetMethod (); if (methodInfo.DeclaringType! = This.GetType ()) {string methodName = frame. GetMethod () .name; var paramInfos = methodInfo.GetParameters (); // Now what ?? How do I get value from paramInfos brake;} and if (i == framccount - 1) {new transport exception ("no legal name can be found Could have been ");} }}}}
You can not self-express your own intestines Can not do this (and since it's fragile, many adaptations may mean that the stack frame is not expected by you, or even the parameter that has been passed, is not actually that the method signing How to suggest (This adapter is entirely possible for the JIT compiler that you only have one sub
ParameterInfo simply tells you that signatures as compiled, not the values that were passed.
Based on the analysis of IL, to create the data and do whatever you want, the only real way to get it automatically is via code injection (some things like AOP).
This is not usually a good idea, if you need to debug, then use some debugger, if you have to be clear about logging.
Becoming a clear reflexive technique < may
Comments
Post a Comment