我可以在没有视图的情况下获取EventAggregator订阅消息吗?
我正在尝试在Prism项目中制作一个模块。该模块没有UI(View,ViewModel)。我希望该模块具有工作EventAggregator事件处理程序。
有什么办法吗?
I'm trying to make a module in a prism project. The module doesn't have UI(View, ViewModel). I want the module has working EventAggregator event handlers.
Is there any way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然是。一个模块只是一个后期的,分离后的代码集合。它可以包含任何东西,无论是查看,查看模型,服务,DTOS ...
...大多数可以注入依赖项,因为它们从容器中解析了。即他们可以使用事件聚合器。
如果您拥有“自己”的服务(即像Windows服务,但在过程中),或者需要提早初始化,则可以在
on Initialization
中解决该服务并开始/启动/初始化它。Of course, it is. A module is just a late-bound, post-deployment-exchangeable collection of code. It can contain anything, be it views, view models, services, dtos...
... most of those can have dependencies injected because they're resolved from the container. I.e. they can use the event aggregator.
If you have services that are "on their own" (i.e. like a windows service, but in-process) or that need to be initialized early, you can resolve the service in
OnInitialized
and start it/initialize it.