The code in question is kinda in-between a couple versions I am playing around with, so I won't bother posting all of it since it won't help
I have a class called EventManager which basically receives a generic Event, iterates through a list of EventHandlers for that specific Event and calls a dispath() method on each of those Handlers.
dispatch utilizes Reflection in order to call a method by name that wants to handle the raised Event. Let me know if I've lost you yet
All of the above works fine. Now for the 'dilemna' (I wouldn't call it a problem, just a matter of deciding which solution is better).
A class that wants to handle a raised event can have any name it wants, but it must accept the type of arguments that dispatch() specifies. Since there are a number of events, dispatch() calls the handling object's method and passes a generic superclass. The handling method must then cast to a sub-class if they want to access the sub-class data. I find this less than pretty and somewhat error prone.
The alternative is to write seperate dispatch() methods for every single Event type (there are a lot) so that the parent class does not have to be the argument. This makes it safer/easier for the handling methods, but significantly sloppier looking with all the dispatch methods (and very redundant code).
There is a third option. One dispatch method could be written accepting the parent class. The dispatch method could then switch on the type of event and call the handling event with the proper child class. The problem I see with this approach is that you are switching and casting multiple times for the same object because dispatch will be called multiple times for a single event if there are multiple handlers for that event.
Thoughts? Am I being too vague?