avatar
s*i
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?
avatar
c*e
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?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。