MEFilicious Applications              Owen Evans            Developer - Xero       @buildmaster http://bgeek.net
What is MEF• Managed Extensibility Framework • Standards for exposing yourself! • Open/Closed principal • It’s all so META
ComposablePart• The building block of a MEF enabled  application • Defines an [Import] or [Export] (or    both)
Catalog - a collection of         parts• Catalogs are how you define which parts  are available to the system • Directory C...
CompositionContainer• Similar to an IoC container• Wires everything together and satisfies  dependancies
demo time...  MEF 101
MEF steps• Create a catalog (or collection of catalogs)  var
catalog
=
new
AggregateCatalog(new
DirectoryCatalog(@"."),new...
Filtering• Catalogs can be filtered down using a  FilteredCatalog*  (* source code available here: http://bit.ly/  MEFFilter)
demo time...Filtered Catalog
Recomposition• Import points can be marked as  recomposable • New instances in the catalog matching    the import will cau...
demo time...Recomposition
Lifetime• Export providers can decide on the lifetime  of their parts:  • Shared: only one instance per container  • NonSh...
demo time...Creation Policy
Thats all there is to        MEF
MEF is:• A framework for creating extensible  applications• Puts focus on discovery of parts at run  time• as such...
MEF is not•   IoC    •   Inversion of Control is about knowing what        dependancies satisfy given classes and allowing...
Did I say I’m running a Web Dev Conference?               http://wdcnz.com
MEFilicious Applications
MEFilicious Applications
MEFilicious Applications
Upcoming SlideShare
Loading in …5
×

MEFilicious Applications

591 views

Published on

Slides from my MEFIlicious applications talk at the Wellington .NET user group

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
591
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • MEFilicious Applications

    1. 1. MEFilicious Applications Owen Evans Developer - Xero @buildmaster http://bgeek.net
    2. 2. What is MEF• Managed Extensibility Framework • Standards for exposing yourself! • Open/Closed principal • It’s all so META
    3. 3. ComposablePart• The building block of a MEF enabled application • Defines an [Import] or [Export] (or both)
    4. 4. Catalog - a collection of parts• Catalogs are how you define which parts are available to the system • Directory Catalog • Assembly Catalog • Aggregate Catalog
    5. 5. CompositionContainer• Similar to an IoC container• Wires everything together and satisfies dependancies
    6. 6. demo time... MEF 101
    7. 7. 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>();
    8. 8. Filtering• Catalogs can be filtered down using a FilteredCatalog* (* source code available here: http://bit.ly/ MEFFilter)
    9. 9. demo time...Filtered Catalog
    10. 10. Recomposition• Import points can be marked as recomposable • New instances in the catalog matching the import will cause the collection to be rebuilt
    11. 11. demo time...Recomposition
    12. 12. 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)
    13. 13. demo time...Creation Policy
    14. 14. Thats all there is to MEF
    15. 15. MEF is:• A framework for creating extensible applications• Puts focus on discovery of parts at run time• as such...
    16. 16. 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.
    17. 17. Did I say I’m running a Web Dev Conference? http://wdcnz.com

    ×