CAB/SCSF 命令与事件
CAB 中的命令和事件有什么区别?似乎做同样的事情,什么时候使用命令意图和事件?
What is the difference between the Commands and the Events in CAB? There seem to do the same thing, when is the command intent to be used and the events?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 CAB 的角度来看,命令专门用于 UI 组件,而事件理论上可以由任何组件使用。因此,命令是 UI 菜单、操作等事件机制的更具体实现...
以下是 Rich Newman 在 CAB 上撰写的精彩文章系列的链接。第 10 章和第 11 章介绍 CAB 中的命令和事件。
http://richnewman.wordpress.com/intro-to-cab-toc/
http://richnewman.wordpress.com/2007/09/22/introduction-to-events-in-the-cab-introduction-to-cabscsf-part-11/
http://richnewman.wordpress.com/ 2007/09/16/cabscsf-part-10 驾驶室命令简介/
From a CAB point of view commands were meant to be used specifically for UI components, while events could in theory be used by any component. So commands are a more specific implementation of the event mechanism for UI menus, actions, etc...
Below are links to an excellent article series by Rich Newman on CAB. Chapter 10 and 11 are on commmands and events in CAB.
http://richnewman.wordpress.com/intro-to-cab-toc/
http://richnewman.wordpress.com/2007/09/22/introduction-to-events-in-the-cab-introduction-to-cabscsf-part-11/
http://richnewman.wordpress.com/2007/09/16/commands-in-the-cab-introduction-to-cabscsf-part-10/
从理论上讲,将 CAB 放在一边;
可以重复使用或不通过
应用程序的不同部分。
意思是“做这个”。
发生了一些事情,所以每个
附加到该事件的实例可能
决定做不同的事情时
该事件已发布。意思是“这个
所以
我想,如果对于给定的操作你总是想做同样的事情,那么使用命令。如果不使用事件。
我目前正在使用 Prism(适用于 Windows 窗体),到目前为止我没有使用事件进行通信。
Leaving CAB aside, by theory;
can be reused or not through
different parts of the application.
means "Do this".
that something happened, so every
instance attached to that event might
decide to do different things when
the event is published. means "this
happened"
So I guess that, if for a given action you want to do always the same thing, then use a command. If not use an event.
I'm currently using Prism (adapted to work with Windows forms) and so far I've not used events for communication.