Successfully reported this slideshow.
Your SlideShare is downloading. ×

When MEF meets Silverlight


Check these out next

1 of 23 Ad

More Related Content

Similar to When MEF meets Silverlight (20)


Recently uploaded (20)

When MEF meets Silverlight

  1. 1. When MEF meets Silverlight<br />AmrElsehemy<br /><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 /><br /><br /><br /><br /> – He is awesome!<br /><br />22<br />
  23. 23. Questions?<br />23<br />
  24. 24. Thank you<br />24<br /><ul><li>Contacts
  25. 25.
  26. 26. twitter @amrelsehemy
  27. 27. Blog</li>

Editor's Notes

  • 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