Silverlight Prism - 成功登录后加载模块/模块之间的依赖关系

发布于 2024-08-12 10:25:27 字数 384 浏览 3 评论 0原文

我有一个 Silverlight Prism 应用程序,其中包含带有登录控件的工具栏模块。我目前在引导程序中将主区域中的一个模块设置为 InitializationMode.OnDemand ,并且可以在工具栏模块中成功登录后通过 ModuleManager.LoadModule() 加载它。然而,这感觉不对,因为它本质上将工具栏模块与其登录后加载的模块紧密耦合。

现在的问题是......这是最佳实践,还是我应该追求从工具栏模块引发 CompositePresentationEvent 并让 shell 加载适当的模块?或者还有其他选择吗?我构建此应用程序是为了了解有关 Prism 的更多信息,并且我希望确保尽可能遵循最佳实践。

I have a Silverlight Prism application that includes a toolbar module with login controls. I currently have a module in the main region set to InitializationMode.OnDemand in the Bootstrapper and can load it via ModuleManager.LoadModule() after a successful login in the toolbar module. However, this doesn't feel right as it's essentially tightly coupling the toolbar module to the module(s) it loads after login.

Now for the question... Is this best practice, or should I pursue something along the lines of raising a CompositePresentationEvent from the toolbar module and having the shell load the appropriate modules? Or are there other options? I'm building this application in an attempt to learn more about Prism and I want to be sure I'm following best practices as much as possible.

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

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

发布评论

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

评论(1

绻影浮沉 2024-08-19 10:25:27

我更喜欢这种情况下的 EventAggregator 方法。我不喜欢一个模块了解另一个模块。 Shell 最多应该了解其他模块,但它们不应该像那样互相干扰。

由于这更多的是 shell 的责任,您是否考虑过将其烘焙到 Shell 本身中?如果它们在逻辑上是相同的,则没有太多理由将它们分开,除非您打算经常更换工具栏。我通常将菜单烘焙到 shell 中,并为模块提供一种通过 IMenuRegistry 等服务为菜单做出贡献的方法。只是一个建议。

I like the EventAggregator approach in this case better. I don't like one module knowing about the other. At most, the Shell should have an awareness of the other modules, but they shouldn't cross-talk like that.

Since this is more of a shell responsibility, have you considered baking this into the Shell itself? If they are logically the same, there's not much reason to keep them separate unless you intend to replace your toolbar often. I generally bake menus into the shell and make a way for Modules to contribute to the menu through a service like IMenuRegistry or something like that. Just a suggestion.

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