When MEF meets Silverlight

3,250 views
3,130 views

Published on

Cairo Code Camp 2010

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

No Downloads
Views
Total views
3,250
On SlideShare
0
From Embeds
0
Number of Embeds
669
Actions
Shares
0
Downloads
22
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • Senior Software at ITWorxTeaching Assistant and pursing Masters at FCISHaving around 17 MS certsHave a blog at
  • 1- Create the app (SL4)2- Create the UI3- Import a Widget4- Export a Widget5- Compose the container.
  • 1- Add a second widget2- Introduce ImportingMany3- Show Lazy4- ExportMetadata5- Custom exports
  • - Say about the choices (Import/Export combination)- How MEF decides to match Export:ContractNameSharedMetadataContractNameCardinalitySharedRecomposableMetadata
  • Container , that has some catalogs which are places where MEF asks how to find matchesAdd an assembly catalog, built in catalog
  • 1- Refactor Things.Extensions2- Make the Allow Recomposible
  • Not just support features extensibilty, but also as a silverlight application everytimexaps are downloaded you try to cut off download size
  • When MEF meets Silverlight

    1. 1. When MEF meets Silverlight<br />AmrElsehemy<br />amr.elsehemy@me.com<br />1<br />
    2. 2. Speaker<br />TA at Faculty of Information and Computer Science Ain Shams University<br />Senior Software Engineer at ITWorx<br />MCSD, MCPD + more.<br />2<br />
    3. 3. What's MEF?<br />The Managed Extensibility Framework<br />“The Managed Extensibility Framework (MEF) is a new library in .NET 4 / Silverlight 4 for building applications that can be incrementally extended” – mef team<br />“An extensible framework for composing applications from a set of loosely-couple parts discovered and evolving at run-time” – mtaulty<br />3<br />
    4. 4. WhywasMEF built?<br />4<br />I need A<br />Put the D<br />Can I have C<br />F<br />E<br />F<br />B<br />A<br />App<br />C<br />G<br />D<br />Add B<br />G<br />Then get me E<br />
    5. 5. Why MEF<br />For customers<br />For you and your team <br />Always there, always ready<br />In the framework!<br />5<br />
    6. 6. MEF Basics…<br />6<br />An Application is built of parts<br />
    7. 7. Demo<br />Building our thing<br />7<br />
    8. 8. 3 Magic steps <br />Export it<br />Import it<br />Compose it<br />8<br />
    9. 9. Export it<br />9<br />[Export(typeof(IThing))]<br />publicclassThing<br />{<br />}<br />IThing<br />Export<br />9<br />
    10. 10. Import it <br />10<br />publicclassMainPage<br />{<br /> [Import(typeof(IThing))]<br /> publicIThing thing;<br />}<br />IThing<br />Import<br />10<br />
    11. 11. Compose it <br />11<br />publicclassMainPage<br />{<br />publicMainPage()<br />{ <br />CompositionInitializer.SatisfyImports(this);<br />}<br />Compose<br />11<br />
    12. 12. Demo<br />Giving more<br />12<br />
    13. 13. Import it - Metadata<br />13<br />[ImportMany]<br />publicIEnumerable<Lazy<IThing, IThingMetadata>> somethings;<br />IThing<br />ImportMany<br />
    14. 14. Export it - Metadata<br />14<br />[ExportMetadata("Position", ThingPosition.Left)]<br />[Export(typeof(IThing))]<br />publicpartialclassThing<br />{<br />}<br />Put me in the left<br />IThing<br />Export<br />
    15. 15. Customize it – Custom exports<br />15<br />[ThingExport(Position = ThingPosition.Left)] <br />publicclassThing<br />{}<br />Put me in the left<br />IThing<br />Export<br />15<br />
    16. 16. Demo<br />Exploring the catalogs<br />16<br />
    17. 17. TypeCatalog<br />AssemblyCatalog<br />AggregateCatalog<br />Compose it – Catalogs<br />17<br />
    18. 18. Demo<br />Trim your apps break up your xaps<br />18<br />
    19. 19. Recomopose- DeploymentCatalog<br />Recomposition is key in Silverlight apps<br />Initial download, small in size.<br />Download more functionality.<br />A special Silverlight catalog DeploymentCatalog.<br />Trace changes with IPartImportsSatisfiedNotification<br />19<br />
    20. 20. MEF here, there, everywhere<br />Samples<br />20<br />
    21. 21. MEF versions<br />.NET Framework shipping with Silverlight4<br />.NET Framework 4 shipping with VS 2010<br />Silverlight 3 & .NET Framework V3.5 SP1<br />Source on Codeplex (MSPL)<br />21<br />
    22. 22. Resources<br />silverlight.net<br />mef.codeplex.com<br />mefcontrib.codeplex.com<br />blogs.msdn.com/gblock<br />mtaulty.com – He is awesome!<br />channel9.msdn.com/tags/learnMEFSL4<br />22<br />
    23. 23. Questions?<br />23<br />
    24. 24. Thank you<br />24<br /><ul><li>Contacts
    25. 25. amr.elsehemy@me.com
    26. 26. twitter @amrelsehemy
    27. 27. Blog http://amrelsehemy.net</li>

    ×