托管扩展性框架中的导出更改是什么意思?
我是 MEF 新手。在托管扩展性框架中,事件导出更改和导出更改是什么意思。如何可视化它?
I'm new to MEF. In Managed Exensibility Framework, what do you mean by events exportschanging and exportschanged. How one can visualize it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在托管可扩展性框架中,对象通过匹配导入和导出来连接在一起。我想你已经知道了。 (如果没有,您应该先通读 MEF 编程指南,然后开始玩与 MEF 有点。)
在典型场景中,导出由类型目录提供。其中一些目录可以在应用程序运行时更改,此时应用程序可能是 重组。
以下是修改目录的两个示例:
DirectoryCatalog.Refresh()
(这将重新扫描目录并选取新程序集)AggregateCatalog.Catalogs.Add
发生这种情况时,
CatalogExportProvider
基于目录将在处理更改之前触发ExportsChanging
事件,并在处理更改之后触发ExportsChanged
事件。并非所有出口提供商都必须基于目录,但我希望您明白这一点。
In the Managed Extensibility Framework, objects are wired together by matching imports with exports. I assume you already know about that. (If not, you should read through the MEF programming guide first and play with MEF a bit.)
In a typical scenario, exports are provided by a catalog of types. Some of these catalogs can be changed while the application is running, at which point the application might be recomposed.
Here are two examples of modifying a catalog:
DirectoryCatalog.Refresh()
(this will rescan the directory and pick up new assemblies)AggregateCatalog.Catalogs.Add
When this happens, the
CatalogExportProvider
based on the catalog will trigger theExportsChanging
event right before handling the change, andExportsChanged
right after.Not all export providers have to be based on catalogs, but I hope you get the idea.