Silverlight mef
Upcoming SlideShare
Loading in...5
×
 

Silverlight mef

on

  • 781 views

 

Statistics

Views

Total Views
781
Views on SlideShare
781
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Silverlight mef Silverlight mef Presentation Transcript

  • Building Modular SilverlightApplications with theManaged Extensibility Framework Ben Dewey twentysix New York http://www.bendewey.com/blog http://twitter.com/bendewey
  • We thank the following companies for their gracious sponsorship Platinum Sponsors Gold Sponsor
  • Assumptions• Basic knowledge of – Silverlight – Model-View-ViewModel• Nice to have knowledge of – Loosely Coupled Application Architecture – Inversion of Control Containers View slide
  • Overview• What is the Managed Extensibility Framework• MEF Basics – Export, Import, Compose• Describing your exports with Metadata• Loading Packages Dynamically• Questions View slide
  • Preface• Loosely Couple Architecture – Extract functionality to Interfaces• Inversion of Control Containers – Dependency Injection IPlugin obj = new MyPlugin(); IPlugin obj = IoC.Resolve<IPlugin>();
  • What is MEF• MEF is the Managed Extensibility Framework – Create based on the needs of the VS2010 team – MEF Preview 9 for SL3 and In the Box for SL4• Why would you want to use it? – Loosely Coupled Application – Plugin Architecture – Limit initial XAP download time.
  • MEF Basics• Export [Export(typeof(IPlugin))] public class MyPlugin : IPlugin { }• Import [Import] public IPlugin Plugin { get; set; } [ImportMany] public IEnumerable<IPlugin> Plugin { get; set; }• Compose – Populates the entire object graph CompositionInitializer.SatisfyImports(this);
  • Describing your Exports with Metadata• Use the ExportMetadataAttribute (0-many) [Export(typeof(IPlugin))] [ExportMetadata(“Order”, 1)] public class MyPlugin : IPlugin { }• Binds using the Lazy<T, TMetadata> object to a strongly typed interface public interface IPluginMetadata { int Order { get; set; } }
  • Recomposition• Imports get set whenever new Exports become available [ImportMany(AllowRecomposition=true)] public IEnumerable<IShape> Shapes { get; set; }
  • Loading Packages Dynamically• DeploymentCatalog, var catalog = new DeploymentCatalog("MefHolidayShapes.xap"); catalog.DownloadCompleted += catalog_DownloadCompleted; catalog.DownloadAsync();• DeploymentCatalogService DeploymentCatalogService.AddXap("MefHolidayShapes.xap");* DeploymentCatalogService is not included in System.ComponentModel.Composition, comes with the DeploymentCatalogSample Sample application
  • Links• http://mef.codeplex.com• http://microsoftpdc.com/Sessions/FT24 – Building Extensible Rich Internet Applications with the Managed Extensibility Framework (Glenn Block)• http://channel9.msdn.com/shows/SilverlightTV/
  • New York City Spring 2010 http://www.agilefirestarter.com twitter: @agilefire Saturday March 27, 2010
  • Thank You