I have a static class, which methods is called from instances of another class. How I can to know which instance has called method without some adding method parameters?
Example:
static class SomeStaticClass
{
public static void SomeGreatMethod (/*NO PARAMETERS*/)
{
LittleClass caller = //How to obtain caller instance here?
}
}
class LittleClass
{
public void SomeMethod ()
{
//some code
SomeStaticClass.SomeGreatMethod (/*NO PARAMETERS*/);
}
}
You can get a StackFrame and read from it entire stack trace