C
Charles Law
I have the following hierarchy
ClassA
contains ClassBCollection
which contains ClassB objects
contains ClassCCollection
which contains ClassC objects
I am using the observer pattern, so in ClassC I have an event Notify, and a
method OnNotify that raises this event. This event must be passed all the
way back up the chain to ClassA.
It is tedious and error prone when I want to add a new event, because I have
to insert AddHandler and RemoveHandler calls at various levels, sink the
event at other levels, and create OnEvent methods all over the place.
Is there a convenient way of automating this, or is there a simpler way to
implement the pattern?
I also encounter the situation where my event sink wants to call
OnNotify(sender, e) in the middle of the chain, but I also want to call
OnNotify(message) as well. I could create two methods, but the pattern does
not seem to imply the need for this. Am I missing something? It's all
getting mighty complicated.
TIA
Charles
ClassA
contains ClassBCollection
which contains ClassB objects
contains ClassCCollection
which contains ClassC objects
I am using the observer pattern, so in ClassC I have an event Notify, and a
method OnNotify that raises this event. This event must be passed all the
way back up the chain to ClassA.
It is tedious and error prone when I want to add a new event, because I have
to insert AddHandler and RemoveHandler calls at various levels, sink the
event at other levels, and create OnEvent methods all over the place.
Is there a convenient way of automating this, or is there a simpler way to
implement the pattern?
I also encounter the situation where my event sink wants to call
OnNotify(sender, e) in the middle of the chain, but I also want to call
OnNotify(message) as well. I could create two methods, but the pattern does
not seem to imply the need for this. Am I missing something? It's all
getting mighty complicated.
TIA
Charles