I have a module (Fody.MethodTimer) that I can extend my classes with attributes. When my class'es method gets executed it, invokes a static method (in another class)
public class CommandBase
{
[Time]
public bool test()
{
return true;
}
}
public static class MethodTimeLogger
{
public static void Log(MethodBase methodBase, long milliseconds)
{
//Do some logging here
}
}
Basically, after the method is call of test is complete, the Log method gets executed. As you can see, it get a MethodBase argument and has all that is needed do decribe the method that invoked this method call.
my Question is, If it is possible to get the object that invoked the Log method Call, out of The .NET MethodBase class instance.
methodBase.DeclaringType.Name
RépondreSupprimer