Tuesday, November 24, 2009

Tim Heuer's Silverlight 4 collection

http://timheuer.com/blog/archive/2009/11/22/pdc-silverlight-resources-link-dump-learn-silverlight.aspx

Just watched the new MEF shipping with Silverlight 4. kind of confusing, I'd better read up on or watch a different video: http://development-guides.silverbaylabs.org/Video/Silverlight-MEF#videolocation_0 talks about "Separation of Concerns": http://en.wikipedia.org/wiki/Separation_of_concerns . The big idea behind MEF seems to be that one can instantiate objects - from the extremely simple such as a string to very complicated such as a database access object - by referencing an object external to the code, say in a different Silverlight App, instead of explicit instantiation by "new". MEF ties the instantiation and the external object together by a string token: The exporting module uses a [Export("MyObject")] decoration above the instantiation, the importing module a matching [Import("MyObject")]. When the import is triggered, the instantiation pointed to by the "Export" happens. This allows the concrete implementation of the needed type to be separate and outside of the core code, and therefore easily extensible and changeable. How does MEF find the right package? The magic seems to be in the PackageCatalog class.

No comments: