As per Phil's post, a Delegate instance has a GetInvocationList() method
that returns an array of Delegates, one for each list.  This is assuming you
have a delegate instance.

I've had other times when I would have like to know if there listeners for a
particular event.

My original problem points to a previous post about
System.Web.UI.WebControls.CheckBox(es) dynamically created within the
context of a Repeater.  What I'm trying to find out (in my feeble efforts to
debug) is if the event, i.e., CheckedChanged has been assigned a delegate
method when the Repeater's ItemDataBound or ItemCreated event is fired.

If you use this reflection code, you can retrieve the Delegate:

EventInfo ev = db.GetType().GetEvent("CheckedChanged");

I can see that it is the Delegate, but cannot cast it.


On 2/14/07, Mike Woodring <[EMAIL PROTECTED]> wrote:

> and the compiler tells me:
> The event 'System.Web.UI.WebControls.CheckBox.CheckedChanged' can only
> appear on the left hand side of += or -=
>
> What might I be doing incorrectly here?
> Is what I want to do even possible?

What are you trying to accomplish functionally?  You can't really do what
you're describing from the 'outside', because the public functionality of
an
event is just what the compiler is telling you about: the ability to add
or
remove a handler.  What the interal implementation is for that event is
off
limits to you - maybe the implementor is leveraging the default
implementation for events, or maybe they've provided custom add/remove
handler that are storing the delegate references being passed to them in a
hashtable or other data structure.  So being able to query whether
anyone's
registered for an event (and if so, how many) isn't part of the public
functionality of an event.

Obviously, any class you write that publishes events can also provide a
property or method that provides that information.  But it's not part of
the
natural event facilities, so you're not going to see it in the MSFT
framework libs - or most others.

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsight.com/mike

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to