views:

55

answers:

1

I have a tree structure

A -> B -> D -> Y
  -> C -> X
       -> X

I want to do an operation on all objects of class X, or all the children objects of class D (for example). I want to call start this operation from any node in the tree (ie recursively).

For e.g,

A.SetupDecorators();

(although I'm open to suggestions)

All classes inherit from a superclass.

Is there a nice OO solution for this without using reflection?

C# is preferred.

+1  A: 

Try Visitor Design Pattern and the example code in C#

Boris Pavlović
thanks! Of course I should've thought of this, already using this pattern...
geejay