简体   繁体   English

IoC元素之间的事件通信

[英]Event communication between IoC elements

I'm using Castle.Windsor IoC for loading plugins on runtime. 我正在使用Castle.Windsor IoC在运行时加载插件。 These plugins provide both logic and UI implementation, such as overview and detail view panes to be inserted into my applications main window. 这些插件提供了逻辑和UI实现,例如要插入到我的应用程序主窗口中的概述和详细信息视图窗格。 Each provided interface implementation contains a path that distinctly references it, and the registration of the classes is in transient lifestyle mode. 每个提供的接口实现都包含一个明确引用它的路径,并且类的注册处于临时生活方式模式。

Now, it seems that I am running into trouble considering communication between (UI) components: Normally I would have added delegate methods to the event queue of the UI elements inside the main windows code. 现在,似乎在考虑(UI)组件之间的通信时遇到了麻烦:通常,我会在主窗口代码内的UI元素的事件队列中添加委托方法。 But since the main window does not know anything specific about the events of the loaded controls, this would not work. 但是由于主窗口不知道有关已加载控件事件的任何特定信息,因此将无法正常工作。

My first workaround would be to resolve the registered instance from the IoC container and attach to its event queue -- but I'm not sure if this works with transient lifestyle mode and not linking to libraries leaves me unaware of the event signatures. 我的第一个解决方法是从IoC容器解析注册的实例并附加到其事件队列中-但是我不确定这是否适用于瞬态生活方式模式,并且未链接到库也使我不知道事件签名。 (What if an element from library A wants to watch another libraries event queue?) (如果库A中的元素想要观看另一个库事件队列怎么办?)

Any ideas on how to solve this? 关于如何解决这个问题的任何想法?

The Event Wiring Facility could help you setup the communication between your different components. 事件接线工具可以帮助您设置不同组件之间的通信。 It is a facility that lets you decouple events in Windsor. 它是一种使您可以在温莎中解耦事件的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM