Download - Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315
![Page 1: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/1.jpg)
![Page 2: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/2.jpg)
Managed Extensibility FrameworkBart J.F. De [email protected]://blogs.bartdesmet.net/bartSoftware Development EngineerMicrosoft CorporationSession Code: DTL315
![Page 3: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/3.jpg)
Agenda
Why extensibility mattersExtensibility the naïve wayMEF versus System.AddinCore conceptsLots of demosSummary
![Page 5: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/5.jpg)
Customer versus developer
Source: http://www.insidefurniture.com Source: http://cristinalaird.files.wordpress.com
![Page 6: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/6.jpg)
Extensibility is hard Looks familiar?
Too hard?
![Page 7: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/7.jpg)
Take a step backinterface IMathBinOp{ string Name { get; } int Calculate(int a, int b);}
IMathBinOp GetOperation(string path, string type){ Assembly asm = Assembly.LoadFrom(path);
return (IMathBinOp)Activator.CreateInstance( asm.Name, type );}
Contract
Dynamic load
Name the 10 problems…
![Page 8: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/8.jpg)
Extensibility the naïve wayBart J.F. De SmetSoftware Development EngineerMicrosoft Corporation
demo
![Page 9: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/9.jpg)
Agenda
Why extensibility mattersExtensibility the naïve wayMEF versus System.AddinCore conceptsLots of demosSummary
![Page 10: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/10.jpg)
Managed Extensibility Framework
Partshave a contract
are found in a catalog
compose in a container
Square with 4 pins
I have these blocks
Let’s build something
![Page 11: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/11.jpg)
System.Addin in a nutshellCross-
process or appdomain
Versioning adaptation
The essence of an add-in
![Page 12: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/12.jpg)
Is System.Addin overkill?
System.AddinIsolation boundariesActivation of add-insAcross CLR versions
MEFComposition engine at its coreUtilities for discoverySimple declarative model
Answer: complimentary technologies
![Page 13: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/13.jpg)
Agenda
Why extensibility mattersExtensibility the naïve wayMEF versus System.AddinCore conceptsLots of demosSummary
![Page 14: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/14.jpg)
A world of give and take
Import
Export
Composed
“I need” “I have”
![Page 15: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/15.jpg)
Composition
Host application
Need a IMathBinOp
Extension A
Have a IMathBinOp
MEF composition
engine
[Export] [Import]
Part
Part
![Page 16: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/16.jpg)
Import and Export in practiceinterface IMathBinOp{ string Name { get; } int Calculate(int a, int b);}
class Calculator{ [Import] public IMathBinOp Operator { get; set; }}
[Export(typeof(IMathBinOp))]class Add : IMathBinOp{ // Implementation}
Contract
Import
Export
Host applicationExtension
![Page 17: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/17.jpg)
How to compose?
CompositionContainerWiring “surface” where magic happens
CompositionBatchContains the parts to be wired together
ContainerBatch
PartCompose
![Page 18: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/18.jpg)
Import and Export in practiceclass App{ static void Main() { var calc = new Calculator();
using (var container = new CompositionContainer()) { var batch = new CompositionBatch(); batch.AddPart(calc); batch.AddPart(new Add()); container.Compose(batch); }
var res = calc.Operator.Calculate(1,2); }}
Manual composition
![Page 19: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/19.jpg)
Simple compositionBart J.F. De SmetSoftware Development EngineerMicrosoft Corporation
demo
![Page 20: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/20.jpg)
Advanced topics in import/export
Named contractsTypically based on TypeCan also be string-based
ImportManyFor use with collectionsE.g. calculator has many operations
Instantiation controlWhich constructor to run?Part creation policies (sharing of instances)
![Page 21: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/21.jpg)
Where do parts come from?
Concept of a catalogType catalog – explicit list of typesAssembly catalog – attributed types in an assemblyDirectory catalog – based on directory searchAggregate catalog – allows combining catalogs
Union operation
ComposablePartCatalog base classQueryable for parts (Parts)Search exports for a given import (GetExports)
![Page 22: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/22.jpg)
Using a DirectoryCatalogclass App{ static void Main() { var calc = new Calculator();
var catalog = new DirectoryCatalog(EXTPATH); using (var container = new CompositionContainer(catalog)) { var batch = new CompositionBatch(); batch.AddPart(calc); container.Compose(batch); }
var res = calc.Operator.Calculate(1,2); }}
Search path
![Page 23: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/23.jpg)
Working with catalogsBart J.F. De SmetSoftware Development EngineerMicrosoft Corporation
demo
![Page 24: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/24.jpg)
Agenda
Why extensibility mattersExtensibility the naïve wayMEF versus System.AddinCore conceptsLots of demosSummary
![Page 25: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/25.jpg)
Selection of MEF Preview 6 samplesBart J.F. De SmetSoftware Development EngineerMicrosoft Corporation
demo
http://mef.codeplex.com
![Page 26: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/26.jpg)
Agenda
Why extensibility mattersExtensibility the naïve wayMEF versus System.AddinCore conceptsLots of demosSummary
![Page 27: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/27.jpg)
The ABC CCC of MEF
Extensibility
Compose
CatalogContract
![Page 28: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/28.jpg)
question & answer
![Page 29: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/29.jpg)
www.microsoft.com/teched
Sessions On-Demand & Community
http://microsoft.com/technet
Resources for IT Professionals
http://microsoft.com/msdn
Resources for Developers
www.microsoft.com/learning
Microsoft Certification & Training Resources
Resources
![Page 30: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/30.jpg)
Complete an evaluation on CommNet and enter to win!
![Page 31: Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315](https://reader035.vdocuments.mx/reader035/viewer/2022062523/5a4d1ad67f8b9ab0599730ae/html5/thumbnails/31.jpg)
© 2009 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.