C
Charles Law
I think I asked the wrong question last time, so I am starting a separate
post to distinguish them.
Take five classes: ClassA and ClassW...Z
ClassA raises five events: Event1...5
ClassW...Z handle some combination of these events. For example
ClassW handles Event1, 2 and 5
ClassX handles Event1, 3 and 4
ClassY handles Event2 and 4
...
At some point, I want to detach ClassX from ClassA, so if I were to write
the code longhand, I would have
RemoveHandler ClassA.Event1, AddressOf ClassX.Event1Handler
RemoveHandler ClassA.Event3, AddressOf ClassX.Event3Handler
RemoveHandler ClassA.Event4, AddressOf ClassX.Event4Handler
This is not so bad for a small number of classes and events, but I actually
have about 30 classes and 50 events. The combinations are too large to
contemplate the longhand approach.
..NET must keep track of what event is linked to what handler somewhere so
that it knows what to call. I am looking for a generic (iterative?) way to
detach handlers from events, given only the source class and target class.
These classes implement interfaces that contain the events and handlers if
that helps.
Can anyone give me any clues?
TIA
Charles
post to distinguish them.
Take five classes: ClassA and ClassW...Z
ClassA raises five events: Event1...5
ClassW...Z handle some combination of these events. For example
ClassW handles Event1, 2 and 5
ClassX handles Event1, 3 and 4
ClassY handles Event2 and 4
...
At some point, I want to detach ClassX from ClassA, so if I were to write
the code longhand, I would have
RemoveHandler ClassA.Event1, AddressOf ClassX.Event1Handler
RemoveHandler ClassA.Event3, AddressOf ClassX.Event3Handler
RemoveHandler ClassA.Event4, AddressOf ClassX.Event4Handler
This is not so bad for a small number of classes and events, but I actually
have about 30 classes and 50 events. The combinations are too large to
contemplate the longhand approach.
..NET must keep track of what event is linked to what handler somewhere so
that it knows what to call. I am looking for a generic (iterative?) way to
detach handlers from events, given only the source class and target class.
These classes implement interfaces that contain the events and handlers if
that helps.
Can anyone give me any clues?
TIA
Charles