我可以在没有视图的情况下获取EventAggregator订阅消息吗?

发布于 2025-01-31 16:41:17 字数 99 浏览 3 评论 0原文

我正在尝试在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云巢 2025-02-07 16:41:17

我想知道可以在没有视图的情况下制作服务模块?

当然是。一个模块只是一个后期的,分离后的代码集合。它可以包含任何东西,无论是查看,查看模型,服务,DTOS ...

我希望模块具有工作EventAggregator事件处理程序。

...大多数可以注入依赖项,因为它们从容器中解析了。即他们可以使用事件聚合器。

如果您拥有“自己”的服务(即像Windows服务,但在过程中),或者需要提早初始化,则可以在on Initialization中解决该服务并开始/启动/初始化它。

I wonder it is possible to make service module without view, viewmodels?

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...

I want the module has working EventAggregator event handlers.

... 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文