Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK...
-
Upload
magdalene-daniels -
Category
Documents
-
view
213 -
download
0
Transcript of Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK...
![Page 1: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/1.jpg)
Change the Rules
Silverlight 4 – A Guided Tour of MEFMike Taulty, Microsoft [email protected]@mtaulty
![Page 2: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/2.jpg)
MEF – What is it? How and when 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– CodePlex version for Silverlight 3, .NET 3.5 Sp1
![Page 3: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/3.jpg)
IAlbumArtProvider
IAlbumInfoProvider
“scenario”
MediaPlayer
AlbumInfoProvider
AlbumArtProvider
GetAlbumInfo(“Blood on the Tracks”)
GetAlbumArt(“Blood on the Tracks”)
Constructor()
Constructor()
![Page 4: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/4.jpg)
Change the Rules
demousing MEF in our scenario
![Page 5: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/5.jpg)
MEF models composable parts
Partexportexport
importimportimport
![Page 6: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/6.jpg)
MEF composes parts
partexport
export
importimport
import
partimportimportimport
partexport
import
part
export
import
import
Composition EngineCompose
part
part
partpartpart
![Page 7: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/7.jpg)
which parts compose together?
partexportexport
importimportimport
partimport
?Contract
Name
Cardinality
Shared
Recomposable
Metadata
Contract
Name
Shared
Metadata
![Page 8: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/8.jpg)
Change the Rules
demomatching imports to exports
![Page 9: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/9.jpg)
parts & part definitions
• PartDefinition is a blueprint for a Part– similar to Object and Type in .NET– but can have Part without
PartDefinition
Partexportexport
importimportimportPartDefinition
export
import
CreatePart()
![Page 10: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/10.jpg)
container draws parts from catalogs
CompositionContainer
Catalog
Catalog Catalog Catalog
PartDefinitionPartDefinitionPartDefinitionPartDefinitionPartDefinitionPartDefinitionPartDefinitionPartDefinition
PartDefinitionPartDefinitionPartDefinitionPartDefinition
![Page 11: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/11.jpg)
or mix in pre-instantiated parts
CompositionContainerpart
Exports(“Foo”)
Compose()part
Imports(“Foo”)
![Page 12: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/12.jpg)
Change the Rules
demothe built-in catalogs*(* one is missing, we’ll come back to it later )
![Page 13: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/13.jpg)
things change - recomposition
CompositionContainer
Catalog Catalog
PartDefinitionPartDefinition PartDefinition
part
Compose()partpart
PartDefinitionSome catalogs support additions
New parts [introduced to/removed from] container may have an impact on this import – a part can opt-in to allow this recompositionpart?
![Page 14: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/14.jpg)
recomposition is key for Silverlight
MyApp.xap
initial, small download
Extras.xapadditional functionality
![Page 15: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/15.jpg)
Change the Rules
demorecomposition & DeploymentCatalog( completing our story of built-in catalogs )
![Page 16: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/16.jpg)
CompositionContainer
stable composition
reject parts with unsatisfied imports
part
partrequires
requires
missing
reject changes that break “agreements”
part
part
requires exactlyone part
part
different part,same contract
![Page 17: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/17.jpg)
Change the Rules
demostable composition
![Page 18: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/18.jpg)
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
model(“data”)
viewmodel(state & data for view)
view(declarative XAML)
commands
binding
![Page 19: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/19.jpg)
Change the Rules
demoMEF and MVVM
![Page 20: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/20.jpg)
Change the Rules
Pointers to more advanced topics
![Page 21: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/21.jpg)
extensibility – catalogs & export providers
CompositionContainer
ExportProvider
ExportProvider...CompositionContainer
ComposablePartCatalog
Catalog
ExportProviderCatalogExportProvider
ExportProviderAggregateExportProvider
ExportProvider
CatalogExportProvider
![Page 22: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/22.jpg)
MEF Primitives
extensibility – programming models
• Programming models in MEF are pluggable
• [Attribute] is the built-in model
• Custom models involve implementing some/all of MEF’s primitive classes
ComposablePartCatalog
ComposablePartDefinition
ComposablePart
ExportDefinition
ImportDefinition
![Page 23: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/23.jpg)
resources
• Channel 9 Silverlight 4 MEF Screencasts– channel9.msdn.com/tags/learnMEFSL4
• Glenn Block– blogs.msdn.com/gblock
• Nicholas Blumhardt– blogs.msdn.com/nblumhardt
• MEF on CodePlex– mef.codeplex.com
![Page 24: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/24.jpg)
thank you
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
![Page 25: Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty.](https://reader035.fdocuments.in/reader035/viewer/2022070408/56649e705503460f94b6e664/html5/thumbnails/25.jpg)
Change the Rules
Silverlight 4 – A Guided Tour of MEFMike Taulty, Microsoft [email protected]@mtaulty