按名称提出事件 [英] raising events by name

查看:110
本文介绍了按名称提出事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,让我们说用户在文本框中输入一个事件名称,并希望

来提高它..

是否可以调用事件由他们的''名字''?

是否有可能枚举app内的事件。并检查他们的名字?

So, let''s say that a user enters an event name in text box, and would like
to raise it..
is it possible to call events by their ''name''?
Is it possible to enumerate events inside app. and to check their names?

推荐答案

是否可以枚举app内的事件。检查他们的名字?

是的;通过反射或System.ComponentModel。这允许你添加/删除

事件订阅,但它不允许你调用事件。

除非你讨厌,你只能访问* public *

事件的一部分,(至少在C#中)只是添加/删除访问器方法。

基础代理*通常是*私有字段,但也可以在一个EventHandlerList,一个Dictionary<,>或者某个父/子实例上的




简而言之,没有强大的功能任意课程的单一方式。


Marc

Is it possible to enumerate events inside app. and to check their names?
Yes; via reflection or System.ComponentModel. This lets you add/remove
event subscriptions, but it doesn''t allow you to invoke the event.
Unless you hack about, you only have access to the *public* part of the
event, which (in C# at least) is just the add/remove accessor methods.
The underlying delegate is *often* a private field, but could also be in
an EventHandlerList, a Dictionary<,>, or on some parent/child instance.

In short, there is no robust single way of doing this for arbitrary classes.

Marc


buu,

当用户在框中输入名称时,这不是

输入数据旁边的事件。


键用来进入的是事件,输入的动作完成了

与事件无关。


你通过一个简单的动作混合一个事件您可以使用有条件的

运算符。


Cor


" buu" < ah*@a.comschreef在bericht

新闻:12 *************** @ news.vmware.amis.hr ...
buu,

As a user enters a name in a box, then that is not an event beside the
entering of the data.

The keys used to enter are events, the action done by what is entered has
nothing to do with an event.

You mix up an event by a simple action that you can do with a conditional
operator.

Cor

"buu" <ah*@a.comschreef in bericht
news:12***************@news.vmware.amis.hr...

所以,让我们说用户在文本框中输入一个事件名称,并希望

来提升它..

是否可以通过名称调用事件?

是否可以枚举应用内的事件。并检查他们的名字?
So, let''s say that a user enters an event name in text box, and would like
to raise it..
is it possible to call events by their ''name''?
Is it possible to enumerate events inside app. and to check their names?


我做了一个错误的例子..

但是,让我说我想提高我知道的一些事件只有

名字

" Cor Ligthert [MVP]" < no ************ @ planet.nlwrote in message

news:11 ****************** **************** @ microsof t.com ...
I took a wrong example..
but, lets say that I would like to raise up some events wich I know only by
name
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:11**********************************@microsof t.com...

buu,


当用户在框中输入名称时,这不是

输入数据旁边的事件。


使用的密钥进入是事件,通过输入的动作完成了

与事件无关。


你通过一个简单的动作混合一个事件你可以使用有条件的

运算符。


Cor


" buu" < ah*@a.comschreef在bericht

新闻:12 *************** @ news.vmware.amis.hr ...
buu,

As a user enters a name in a box, then that is not an event beside the
entering of the data.

The keys used to enter are events, the action done by what is entered has
nothing to do with an event.

You mix up an event by a simple action that you can do with a conditional
operator.

Cor

"buu" <ah*@a.comschreef in bericht
news:12***************@news.vmware.amis.hr...

>所以,让我们说用户在文本框中输入一个事件名称,并且想要提高它...
是可以通过名称调用事件吗?
是否可以枚举应用程序内的事件。检查他们的名字?
>So, let''s say that a user enters an event name in text box, and would
like to raise it..
is it possible to call events by their ''name''?
Is it possible to enumerate events inside app. and to check their names?



这篇关于按名称提出事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆