什么是聚合目录?

发布于 2024-10-03 16:22:59 字数 375 浏览 1 评论 0原文

What is AggregateCatalog? What does it mean when you construct a new AggregateCatalog()? What does it mean when you add assemblies to the catalog, eg catalog.Catalogs.Add(new AssemblyCatalog(someAssembly))? Other than assemblies what can you add to the catalog? any general knowledge related to this would be helpful, too (I'm a total noob)

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

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

发布评论

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

评论(2

北风几吹夏 2024-10-10 16:22:59

MEF 中的 AggregateCatalog 基本上允许您收集多个扩展目录。当您调用 new AggregateCatalog() 时,您基本上是在实例化一个新的目录集合(不一定已填充),该集合可以包含 ComposablePartCatalog 的多个实例,而 ComposablePartCatalog 可以包含多个部分。

将其视为一个可以帮助您从多个集合中收集零件的类。

程序集只是将部件推送到调用应用程序的一种方式。您可以直接从现有装配体内部传递零件。

有关目录的更多信息,我建议阅读

AggregateCatalog in MEF basically allows you to collect multiple extension catalogs. When you call new AggregateCatalog(), you are basically instantiating a new catalog collection (not necessarily populated) that can contain multiple instances of ComposablePartCatalog, which can contain multiple parts.

Consider it a class that helps you collect parts from multiple sets.

Assemblies are just a way to push parts to the calling application. You can pass parts directly from inside the existing assembly.

For more information about catalogs, I would recommend reading this.

栩栩如生 2024-10-10 16:22:59

Mef 的学习曲线很小 - 至少浏览一次 mef.codeplex.com 上的文档。或者,如果您确实时间紧迫,请尝试截屏视频。

这个想法是,目录是导出部件(要注入的对象)或需要导入的部件(需要注入对象)的字典。可以通过多种方式填充目录(因此 diff 目录派生) -- 来自目录(所有 asm 都在一个目录中)或特定程序集。

接下来,您可以创建一个复合目录,例如,您要创建一个字典,其中包含从 DirA 和 DirB 中的特定程序集导出的所有对象。在这种情况下,您可以创建单独的目录,然后创建将两者合并的复合目录。现在,您在代码中使用这个合并的字典来请求导入/导出。

Mef has a small learning curve - go thru the docs at mef.codeplex.com atleast once. Or try screencasts if you're really pressed for time.

The idea is that a catalog is a dictionary of exported parts (objects to be injected) or parts that need imports (that need injected objects).. The catalog can be populated in multiple ways (hence the diff Catalog derivations) -- from a Directory (all asm in a dir) or a Specific assembly.

Next you can create a composite catalog e.g. you want to create a single dictionary that contains all exported objects from DirA and from this specific assembly lying in DirB. In this case, you can create individual catalogs and then a composite catalog which merges the two. Now you consume this merged dictionary in your code to ask for imports/exports.

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