S
Sgt. Sausage
NOTE: I'm new to c#, but not to programming.
For reasons unimportant to the discussion below, I need to be able
to dynamically, at run time, discover the set of all objects listening to
another object's events.
Given some jRandomType, I've figured out how to get the Events
themselves via reflection and GetEvents/EventInfo. This will give me
a list of the Events that jRandomType wants to raise -- but that's only
half the battle.
Now, the part that's got me stumped: Once I have a list of Events
that a Type raises, how do I get from there to iterating through the
subscribers that are listening to the Events on some instance of
jRandomType?
I understand that the Events are defined by the *class*, and the
listeners are registered on a particular *instance* of that class -- e.g.
a given class may raise a single Event, but three instances of that
class may have three different listeners registered. That's not a big
conceptual problem for me. But -- given that I can find the Events
raised via reflection, how do I find out what's subscribed as a
listener on a particular instance?
Is this a case of "you can't get there from here" ? Or, is there an
easy way I'm not finding in the docs?
Thanks for your help.
For reasons unimportant to the discussion below, I need to be able
to dynamically, at run time, discover the set of all objects listening to
another object's events.
Given some jRandomType, I've figured out how to get the Events
themselves via reflection and GetEvents/EventInfo. This will give me
a list of the Events that jRandomType wants to raise -- but that's only
half the battle.
Now, the part that's got me stumped: Once I have a list of Events
that a Type raises, how do I get from there to iterating through the
subscribers that are listening to the Events on some instance of
jRandomType?
I understand that the Events are defined by the *class*, and the
listeners are registered on a particular *instance* of that class -- e.g.
a given class may raise a single Event, but three instances of that
class may have three different listeners registered. That's not a big
conceptual problem for me. But -- given that I can find the Events
raised via reflection, how do I find out what's subscribed as a
listener on a particular instance?
Is this a case of "you can't get there from here" ? Or, is there an
easy way I'm not finding in the docs?
Thanks for your help.