How do I set properties related to the calling method's scope?
- by Thiado de Arruda
I'm not looking for a way to associate values with a thread using the 'SetData' method.
I need to store some kind of data that will only exist during the scope of a calling method, could be the immediate parent or any other call that is made down on the stack.
For example:
void SomeMethod()
{
string someInfo = "someInfo";
SomeOtherMethod();
object data = GetDataOnCurrentScope("someKey");
}
void SomeOtherMethod()
{
SetDataOnParentScope("someKey", somevalue);
}
In this case both the 'someInfo' local variable and the data set with the "someKey" key will disapear after 'SomeMethod' returns. Is something like this possible? This may go against the rules of a stack, but who knows if someone has an idea...