问题
is it possible to get the parameter values of a function call in a static class? I do not own the Class, so I cannot edit the code. And overriding does not work on static classes. However, I can call the function with my own parameters without a problem.
During run time the program will call the function with specific parameters which I need to find out.
I read that it is possible with an interceptor but there are different ways how to do so. Which one should I choose to solve this?
I would be very thankful for a small example or tutorial :)
回答1:
What you're asking for is typically called aspect-oriented interception (or AOP interception). In particular, what it sounds like you want to do is aspect-oriented logging. more information about that can be found at Logging with AOP in .net
There's limits to what you can do with interception depending on your deployment scenarios (e.g. if you're deploying to a least privilege environment, it may not work). You generally use a framework for AOP and interception. One such framework is PostSharp.
Fortunately there are some good Pluralsight courses on AOP and PostSharp: http://www.pluralsight-training.net/microsoft/Courses/TableOfContents/aop
来源:https://stackoverflow.com/questions/11561184/finding-out-parameter-values-of-method-call-static-class-which-i-do-not-own