简体   繁体   中英

Call a method on every call

This can be a debugging/monitoring process.

I want to know a way, preferably the best way, of calling a method every time other methods in a class/namespace/application are executed.

Code snippets, opinions and articles would be appreciated.

AOP; look at PostSharp, for example, which offers this type of weaving. Note that this approach works by chaning the IL during the build process, and may impact runtime performance if over-used.

Take a look at Aspect Oriented Programming(AOP). A good library for this is Postsharp .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM