Extensibility Framework Georges Legros georgeslegros Agenda Introduction MEF vs DI Basic Import Export Instance management Metadata Dynamic Composition Extensibility Managed ID: 278505
Download Presentation The PPT/PDF document "Managed" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Managed Extensibility Framework
Georges Legros
@
georgeslegrosSlide2
AgendaIntroductionMEF vs DI
Basic Import / ExportInstance managementMetadataDynamic CompositionExtensibilitySlide3
Managed
Extensibility FrameworkThe Managed Extensibility Framework (or
MEF
for short) simplifies the creation of extensible applications.
MEF
offers discovery and composition capabilities that you can leverage to load application extensions.
http://mef.codeplex.comSlide4Slide5
MEF vs DIExtensibility / plug-inDiscovery
Metadata for querying and filteringRecompositionSlide6
MEF vs DIDI/
IoC containers focus on those things you know where MEF focuses on those things you don't…I know I will use one logger in a Unit Test, and a different Logger in my app
VsThere are 1 to n loggers that may appear in my systemSlide7
Basic Import / ExportStep 1: Declare
a « Contract »InterfaceStringBothStep 2: Import / ImportMany
Step 3: guess what… ExportSlide8
DEMO 01
Managed Extensibility FrameworkSlide9
Instance ManagementPartCreationPolicy
SharedNonSharedAny (WTF ???)Default: Shared
[PartCreationPolicy(
CreationPolicy
.Shared
)] Slide10
DEMO 02
Managed Extensibility FrameworkSlide11
Instance ManagementLazy<T>
Instance created on demandExportFactory<T>Creation of a fresh
instance each timeSilverlight onlyWill integrate desktop in V2Slide12
DEMO 03
Managed Extensibility Framework
& 03_2Slide13
MetadataLazy<T>
Instance created on demandExportFactory<T>Creation of a fresh
instance each timeSilverlight onlyWill integrate desktop in V2Slide14
DEMO 04
Managed Extensibility FrameworkSlide15
Metadata (2)Evil
strings are EVILSolution -> Custom ExportAdvantage:Strongly typed
Less error proneEasy to discover all possible metadata
properties
Disadvantage
Have to
share
some
code
with
clientsSlide16
DEMO 04_2
Managed Extensibility FrameworkSlide17
Dynamic CompositionDesktop app
AssemblyCatalogDirectoryCatalogCan load multiple timeCan
unloadSlide18
DEMO 05
Managed Extensibility FrameworkSlide19
Dynamic CompositionSilverlight
Deployment CatalogDownload ProgressDownload Completed
Auto downloadRelative pathSlide20
DEMO 06
Managed Extensibility FrameworkSlide21
Extensibility2 ways to
extend MEFExportProviderCreate your own
Catalog & coSlide22
LAST DEMO
Managed Extensibility FrameworkSlide23
Any questions ?Slide24
Thank you!Slide25
Sources & Referenceshttp://mef.codeplex.com
http://ayende.com/blog/3611/the-managed-extensibility-frameworkhttp://code.dortikum.net/2011/01/05/extending-mef/http://codepaste.net/yadusn (Glenn Block)