s*i 发帖数: 5025 | 1 Suppose you have a class (class1), with an event (e). Then you may add many
handlers (h1, h2, ...) like this:
class1.E+=h1;
class1.E+=h2;
.....
You may also remove some during run time like thisL
class1.E-=h1;
...
Now my question is : is there an easy way to find out all the handlers that
are associated with the class event? | c**e 发帖数: 2558 | 2 if you have access to class1's code, you can call GetInvocationList() on E
from within the class and return the handlers as Delegate[] to the client code
.
i don't think code outside class1 can directly manipulate E because the whole
point of decorating E with the 'event' keyword is to prevent it from being
raised by classes other than class1.
you might be able to get around that limitation, or feature rather, using
reflection, but i doubt it.
【在 s*i 的大作中提到】 : Suppose you have a class (class1), with an event (e). Then you may add many : handlers (h1, h2, ...) like this: : class1.E+=h1; : class1.E+=h2; : ..... : You may also remove some during run time like thisL : class1.E-=h1; : ... : Now my question is : is there an easy way to find out all the handlers that : are associated with the class event?
|
|