7. Catalog - a collection of
parts
• Catalogs are how you define which parts
are available to the system
• Directory Catalog
• Assembly Catalog
• Aggregate Catalog
10. MEF steps
• Create a catalog (or collection of catalogs)
var catalog = new AggregateCatalog(new DirectoryCatalog(@"."),new
AssemblyCatalog(Assembly.GetExecutingAssembly()));
• Add catalog(s) to container
var container = new CompositionContainer(catalog);
• Get a type from the container
var window = container.GetExportedValue<CashMaker>();
11. Filtering
• Catalogs can be filtered down using a
FilteredCatalog*
(* source code available here: http://bit.ly/
MEFFilter)
13. Recomposition
• Import points can be marked as
recomposable
• New instances in the catalog matching
the import will cause the collection to be
rebuilt
15. Lifetime
• Export providers can decide on the lifetime
of their parts:
• Shared: only one instance per container
• NonShared: each export will create a
new instance
• Any: allows any use (can be defined on
import)
18. MEF is:
• A framework for creating extensible
applications
• Puts focus on discovery of parts at run
time
• as such...
19. MEF is not
• IoC
• Inversion of Control is about knowing what
dependancies satisfy given classes and allowing the
class to hand this requirement off
• IoC containers are great at saying => “When asking
for an IDependancy you should get Dependancy”
• MEF doesn’t have a way of doing this
• MEF says I have all these objects and you want
some of them... HERE.
20. Did I say I’m running a Web Dev Conference?
http://wdcnz.com