Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

When MEF meets Silverlight

3,378 views

Published on

Cairo Code Camp 2010

Published in: Technology
  • Be the first to comment

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>

×