基本上,我有以下情况:
- 用户运行应用程序
- Bootstrapper 将“模块”目录加载到 AggregateCatalog 中。
- 我的导航菜单已建成
- 用户点击刷新
- 该应用程序下载一个新模块并将其复制到模块目录中。
我不知何故需要能够将新模块添加到我的 AggregateCatalog 并更新我的导航菜单。我认为“AllowRecomposition”是必要的,但是在我的应用程序已经运行后,如何将新程序集实际添加到我的 AggregateCatalog 中?
基本上,我有以下情况:
我不知何故需要能够将新模块添加到我的 AggregateCatalog 并更新我的导航菜单。我认为“AllowRecomposition”是必要的,但是在我的应用程序已经运行后,如何将新程序集实际添加到我的 AggregateCatalog 中?
如果你导入 AggregateCatalog,你可以从你的 ViewModel 中访问它(或者你想添加到它的任何地方。
[Import()]
private AggregateCatalog _aggregateCatalog;
...
private void SomeFunc()
{
_aggregateCatalog.Catalogs.Add(...);
}
IFooService
导出...
//Exception Thrown
[ImportMany(typeof(IFooService))]
private IEnumerable<IFooService> _myFooServices;
//No Exception Thrown
[ImportMany(typeof(IFooService), AllowRecomposition = true)]
private IEnumerable<IFooService> _myFooServices;
OnImportsSatisfied
如果您再次实现该IPartImportsSatisfiedNotification
接口,您将触发,因此请确保您的应用程序不会因此而出现问题。