Mike Taulty from Microsoft gives a detailed exploration of the Microsoft Extensibility Framework (MEF) with Silverlight 4 to the Silverlight UK User Group.
This presentation was given on 3rd February2010 at the Microsoft "Cardinal Place" office in London.
3. MEF – What is it? How do I get it? the Managed Extensibility Framework an extensible framework for composing applications from a set of loosely-coupled parts discovered and evolving at run-time versions .NET Framework shipping with Silverlight 4 .NET Framework 4 shipping with VS 2010 Silverlight 3 & .NET Framework V3.5 Sp1 Source on CodePlex
4. “scenario” iTunesMediaPlayer Constructor() GetAlbumInfo(“Blood on the Tracks”) IAlbumInfoProvider AlbumInfoProvider Constructor() GetAlbumArt(“Blood on the Tracks”) IAlbumArtProvider AlbumArtProvider
5.
6. Hard to test AlbumInfoProvider in isolation from AlbumArtProvider
7. Hard to drop in a different AlbumArtProvider implementation
8.
9. Easier to test AlbumInfoProvider with anyIAlbumArtProvider
10. Easier to drop in new implementations of IAlbumArtProvider
11.
12. the IoC Container Container iTunesMediaPlayer Get<IAlbumInfoProvider>() AlbumArtProvider AlbumArtProvider Constructor(IAlbumArtProvider) Constructor(IAlbumArtProvider) AlbumInfoProvider AlbumInfoProvider
15. but MEF is not ‘just’ another IoC container an extensible framework for composing applications from a set of loosely-coupled parts discovered and evolving at run-time
18. MEF composes parts import import import import import import import part part part part import import export export export Composition Engine export part part part part part
19. which parts compose together? import import import part export export ? import part
21. parts & part definitions import import import import Part PartDefinition CreatePart() export export export PartDefinition is a blueprint for a Part similar to Object and Type in .NET but can have Part without PartDefinition
22. container draws parts from catalogs PartDefinition PartDefinition PartDefinition PartDefinition PartDefinition PartDefinition PartDefinition PartDefinition PartDefinition import import import PartDefinition import import import PartDefinition import import import PartDefinition Part Part Part Catalog Catalog Catalog export export export export export export Catalog CompositionContainer
23. or mix in pre-instantiated parts part Imports(“Foo”) Compose() part Exports(“Foo”) CompositionContainer
25. things change - recomposition New parts [introduced to/removed from] container may have an impact on this import – a part can opt-in to allow this recomposition part Compose() part? part CompositionContainer part Catalog Catalog Catalog PartDefinition PartDefinition PartDefinition PartDefinition Some catalogs support additions
26. recomposition is key for Silverlight initial, small download MyApp.xap Extras.xap additional functionality
28. stable composition reject parts with unsatisfied imports reject changes that break existing “agreements” part part requires exactly one part requires part part requires CompositionContainer missing different part, same contract part
30. MEF and Model View ViewModel Strong separation of concerns possible with Silverlight development user interface declared in XAML loosely binds to data functionality invoked by declarative commands Encapsulated by the “MVVM” pattern binding model (“data”) viewmodel (state & data for view) view (declarative XAML) commands
32. resources Glenn Block blogs.msdn.com/gblock Nicholas Blumhardt blogs.msdn.com/nblumhardt MEF on CodePlex mef.codeplex.com Channel 9 Silverlight 4 MEF Screencasts channel9.msdn.com/tags/learnMEFSL4
33. feedbackMicrosoft Session Feedback via Twitter @msftsession 10 @mtaulty #sluguk ... session score out of 10 ( 10 is recommended but other scores are possible )