how to work out a design to enable a child object to call its
parent(creator/container) method/property?
Its easy to be done if the child can know/assume its parent, but in my
scenario, many different object can create the same child object,
means the child object's parent is dynamic.
Event is possible, but I need the process in synchornous, as event
process is in asyn.
Class Parent()
{
Child objChild;
Public CallMeBack() {}
}
Class Parent2()
{
Child objChild;
Public CallMeBack() {}
}
Class Parent3()
{
Child objChild;
Public CallMeBack() {}
}
Class Child()
{
? objParent;
objParent.CallMeBack();
}
I attempt to use typecasting and interface, but the Child must be
well-aware of the type of the parent berfore the typecasting.