Finding out parameter values of method call (static class which I do not own).

北战南征 提交于 2019-12-13 03:57:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!