문제

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)

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top