If I have several levels of object containment in an object tree where:
ObjectA
contains a List<ClassB> ObjectBs
=> ObjectB
contains a List<ClassC> ObjectCs
===> And so on...
Is there an easy way/design pattern to access a variable/member of ObjectA through its containing member Object C?
For example:
nameOfObjectA = ObjectC.GetUpmostContainer().GetName()
Curently I am instantiating the tree recursevily and with my knowledge I would need to pass the name of ObjectA
on each instantiation of an object, which will be contained by ObjectA
.
Aucun commentaire:
Enregistrer un commentaire