Presentation is loading. Please wait.

Presentation is loading. Please wait.

By, Ben Dewey Senior Software Developer twentySix New York

Similar presentations


Presentation on theme: "By, Ben Dewey Senior Software Developer twentySix New York"— Presentation transcript:

1 By, Ben Dewey Senior Software Developer twentySix New York http://bendewey.com/blog http://twitter.com/bendewey

2 Assumptions Basic knowledge of Silverlight Model-View-ViewModel Nice to have knowledge of Loosely Coupled Application Architecture Inversion of Control Containers

3 Overview What is the Managed Extensibility Framework MEF Basics Export, Import, Compose Describing your exports with Metadata Loading Packages Dynamically Questions

4 Preface Loosely Couple Architecture Extract functionality to Interfaces Inversion of Control Containers Dependency Injection IPlugin obj = new MyPlugin(); IPlugin obj = IoC.Resolve ();

5 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.

6 MEF Basics Export Import Compose Populates the entire object graph CompositionInitializer.SatisfyImports(this); [Import] public IPlugin Plugin { get; set; } [Export(typeof(IPlugin))] public class MyPlugin : IPlugin { } [ImportMany] public IEnumerable Plugin { get; set; }

7 Describing your Exports with Metadata Use the ExportMetadataAttribute (0-many) Binds using the Lazy object to a strongly typed interface [Export(typeof(IPlugin))] [ExportMetadata(“Order”, 1)] public class MyPlugin : IPlugin { } public interface IPluginMetadata { int Order { get; set; } }

8 Recomposition Imports get set whenever new Exports become available [ImportMany(AllowRecomposition=true)] public IEnumerable Shapes { get; set; }

9 Loading Packages Dynamically DeploymentCatalog, DeploymentCatalogService *DeploymentCatalogService is not included in System.ComponentModel.Composition, comes with the DeploymentCatalogSample Sample application DeploymentCatalogService.AddXap("MefHolidayShapes.xap"); var catalog = new DeploymentCatalog("MefHolidayShapes.xap"); catalog.DownloadCompleted += catalog_DownloadCompleted; catalog.DownloadAsync();

10 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/

11 Microsoft Design Toolbox http://microsoft.com/design/toolbox

12 ben@bendewey.com http://twitter.com/bendewey


Download ppt "By, Ben Dewey Senior Software Developer twentySix New York"

Similar presentations


Ads by Google