找出方法调用的参数值(我不拥有的静态类). [英] Finding out parameter values of method call (static class which I do not own).

查看:62
本文介绍了找出方法调用的参数值(我不拥有的静态类).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在静态类中获取函数调用的参数值?我没有课程,因此无法编辑代码.并且覆盖不适用于静态类. 但是,我可以使用自己的参数调用该函数,而不会出现问题.

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 :)

推荐答案

您所要求的通常称为面向方面的拦截(或AOP拦截).特别是,听起来像您想做的是面向方面的日志记录.有关该信息的更多信息,请访问在.net中使用AOP进行登录

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

根据您的部署方案,拦截功能有一定的局限性(例如,如果您要部署到最低权限的环境中,则可能无法正常工作).通常,您使用AOP和拦截的框架.这样的框架就是PostSharp.

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.

幸运的是,有一些关于AOP和PostSharp的好的Pluralsight课程: http://www.pluralsight-training.net/microsoft/Courses/TableOfContents/哎呀

Fortunately there are some good Pluralsight courses on AOP and PostSharp: http://www.pluralsight-training.net/microsoft/Courses/TableOfContents/aop

这篇关于找出方法调用的参数值(我不拥有的静态类).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆