Prism / MEF - 一旦我的应用程序运行,我稍后如何添加到我的 AggregateCatalog 中?
基本上,我有以下场景:
- 用户运行应用程序
- Bootstrapper 将“Modules”目录加载到 AggregateCatalog 中。
- 我的导航菜单已构建
- 用户单击刷新
- 应用程序下载新模块并将其复制到模块目录中。
我需要以某种方式将新模块添加到我的 AggregateCatalog 中并更新我的导航菜单。我认为“AllowRecomposition”是必要的,但是在我的应用程序已经运行后,如何将新程序集实际添加到我的 AggregateCatalog 中?
Basically, I have the following scenario:
- User runs application
- The Bootstrapper loads the "Modules" directory into the AggregateCatalog.
- My navigation menu is built
- The user clicks refresh
- The app downloads a new module and copies it into the Module directory.
I somehow need to be able to add in the new module to my AggregateCatalog and update my navigation menu. I figure a "AllowRecomposition" is necessary, but how do I actually add the new assembly to my AggregateCatalog after my app is already running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果导入 AggregateCatalog,您可以从 ViewModel 中(或您想要添加到其中的任何其他位置)访问它。
NOTE: If the Assembly would affect any Import or ImportMany statements, they must allow for recomposition or you will get an exception. For example, if your assembly contains another
IFooService
export...NOTE: You will trigger
OnImportsSatisfied
if you implemented theIPartImportsSatisfiedNotification
interface again, so ensure that your application does not have issues because of this.If you import the AggregateCatalog you can access it from within your ViewModel (or wherever else you want to add to it.
NOTE: If the Assembly would affect any Import or ImportMany statements, they must allow for recomposition or you will get an exception. For example, if your assembly contains another
IFooService
export...NOTE: You will trigger
OnImportsSatisfied
if you implemented theIPartImportsSatisfiedNotification
interface again, so ensure that your application does not have issues because of this.