大型 Prism/Silverlight 应用程序 - 多个模块与单个数据服务通信

发布于 2024-09-25 06:39:25 字数 295 浏览 0 评论 0原文

我正在使用 Prism 为大型数据驱动的 Silverlight 应用程序开发框架。我正在为应用程序的不同部分创建多个模块,但所有模块都需要访问来自同一 REST Web 服务的数据。因此,我最初的计划是创建一个单独的数据检索模块,然后使用 EventAggregator 将结果传递给订阅结果事件的其他模块。数据模块不会有 ViewModel,因为没有 View。

所以有几个问题: 1. 我所描述的方法是一种好方法吗?一个模块为其他模块提供支持? 2. 如果没有ViewModel,我可以在数据模块的哪里发布事件?

非常感谢任何提示或建议。

I am developing the framework for what will be a large data-driven Silverlight application using Prism. I am creating multiple modules for different pieces of the application, but all modules need to access data from the same REST webservice. So my initial plan was to create a separate module for the data retrieval and use EventAggregator to then pass results to the other modules that subscribe to the result event. The data module will not have a ViewModel since there is no View.

So a couple of questions:
1. Is the way I have described a good way to do this - one module feeds the others?
2. Where in the data module can I publish events if there is no ViewModel?

Any tips or advice are much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

黒涩兲箜 2024-10-02 06:39:25

您只需注入 EA,就可以在任何组件中发布事件。在这种情况下,您可能会在数据检索完成后发布事件。

然而,这可能不是最好的方法。我会采取的方法是为 WebService 创建一个接口并将其注册到容器中。不同的模块可以从容器获取服务实现并自行请求数据,而无需依赖“馈送通知”。

Codeplex 的 Prism 论坛 中有很多讨论此问题的帖子。

You can publish events in any component, by just getting the EA injected. In this case you would probably publish the event once the data retrieval is complete.

However, this might not be the best approach. The one I would take is creating an interface for the WebService and registering it in the container. Differnt modules can get the service implementation from the container and request the data on their own without depending on a "feeding notification".

There are many threads discussing this in the Prism forums at Codeplex.

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