Pavel Minaev
5/25/2008 8:17:00 PM
On May 22, 1:54 am, "Bruce C. Miller" <bm3...@gmail.com> wrote:
> So, say I have an instance of a .Net object with a collection of
> events. It is possible to get at these events and look at them with
> various relection-type properties. However, would it be possible to
> take another instance of the same type of .Net object, grab all of the
> event handlers off of the old object, and stick them onto the new
> one?
>
> That is, do have access to these event handler methods (which are
> delegates) from just looking at an instantiation of the object, and
> can I pull them off and add them as event handlers on another object
> of the same type?
No. The whole point of having events as a distinct entity to
properties/fields of delegate type is encapsulation - only object
itself can inspect the list of event handlers (a particular case of
this is calling all the handlers), and objects of other classes can
only subscribe and unsubscribe.