370 likes | 560 Views
Building Extensible Rich Internet Applications with the Managed Extensibility Framework. Glenn Block Program Manager Microsoft Corporation. What we’ll cover. RIA Extensions, add-ins , and plugins oh my!. Extensibility implants. Turning fat apps into slimmer apps. Reality. RIA 1.0.
E N D
Building Extensible Rich Internet Applications with the Managed Extensibility Framework Glenn Block Program Manager Microsoft Corporation
Reality RIA 1.0
We need….. Reality We need….. We need….. We need….. K We need….. F A E We need….. J I D RIA 1.0 C B H G We need….. We need….. We need…. We need….
Managed Extensibility Framework The Managed Extensibility Framework (MEF) is a new library in Silverlight 4 for building applications that can be incrementally extended. • For customers • For you and your team • Always there, always ready
MEF Basics… An Application is built ofparts.
MEF Basics… Export it. Import it. Composeit.
Export it. [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 UserControl Export
Import it. [Export(typeof(UserControl))] public class Widget1 : UserControl { [Import] public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 String Import
Import it. [Export(typeof(UserControl))] public class Widget1 : UserControl { [Import(“HelloMEF.Message”)] public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 “HelloMEF.Message” Import
Import it. [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<UserControl> { get;set; } } Main Page UserControl ImportMany
Compose it. PartIntializer: “Compose yourself” public MainPage() { InitializeComponent(); PartInitializer.SatisfyImports(this); } MainPage Compose
Where does the widget go? Widget Widget
Export it - Metadata [ExportMetadata(“Location”,Location.Top)] [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 Put me in the top UserControl Export
Import it - Metadata [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<Lazy<UserControl, IWidgetMetadata> { get;set; } } Main Page UserControl ImportMany
Export it - Metadata [ExportMetadata(“Location”,Location.Top)] [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 Put me in the top UserControl Export
Customize it – Custom exports [Widget(Location=Location.Top)] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 Put me in the top UserControl Export
MEF and Prism partner Ariel Ben-Horesh arielb@sela.co.il blogs.microsoft.co.il/blogs/arielbh Developer Sela Group
Introducing MEF-Prism integration • Our Goal : Enable an existing Prism application to be further extended through MEF • Enabled MEF modules to be added dynamically on the fly. • Enable MEF discovered components to be registered in IoC container (Such as Unity).
Introducing MEF-Prism integration • Prism application starts and loads up known modules. Module Loader
Introducing MEF-Prism integration • Prism application can load unknownplugins, by using MEF as an abstraction layer. • 1. Plugins are located and added to a MEF catalog. Server
Introducing MEF-Prism integration • Prism application can load unknownplugins, by using MEF as an abstraction layer. • 2. Plugins register dependencies with current IoC container. Server
Introducing MEF-Prism integration • Prism application can load unknownplugins, by using MEF as an abstraction layer. • 3. Plugins are activated. Dependencies are injected. Server
Where can I get it? • MEF ships in Silverlight 4.0 • Dynamic XAP support in SL 4.0 Toolkit • Silverlight 3.0 support on Codeplex • MEF source ships under MSPL Learn more: Silverlight.net MEF.Codeplex.com MEFContrib.Codeplex.com – Prism/MEF blogs.msdn.com/gblock
MEF Cross-platform(s) partner Jackson Harper jackson@novell.com blog.MonoOnTheWeb.info Software Engineer Moonlight Project
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation forms online at MicrosoftPDC.com
Learn More On Channel 9 • Expand your PDC experience through Channel 9 • Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses channel9.msdn.com/learn Built by Developers for Developers….