Can I find out if the method is called in the application?

I wanted to try something, but I don’t know if it is possible. I want my code to listen on a third-party application method. I try to work when a method is called, and also to retrieve any arguments passed to this method.

For example, the method is called in a third-party application, as shown below:

LoggerClass.LogCreate(LogName, LogDetails) 

I would like to know when LogCreate is called and then retrieves the information by retrieving the LogName and LogDetails strings. Then I would parse 2 lines for my own logger utility.

Is it possible?

Thanks in advance.

+4
source share
1 answer

This is exactly what Aspect Oriented Programming is included.

The Wikipedia article linked above suggests that it is supported in C # but does not provide details. Maybe someone else here can - I don't do C # myself ...

If you didn't find support directly in C #, you can check out PostSharp .

0
source

Source: https://habr.com/ru/post/1410972/


All Articles