0
Building Extensible Rich Internet Applications with the Managed Extensibility Framework<br />Glenn Block<br />Program Mana...
What we’ll cover<br />
RIA Extensions, add-ins, and plugins oh my!<br />
Extensibility implants<br />
Turning fat apps into slimmer apps<br />
Reality<br />RIA 1.0<br />
Reality<br />We need…..<br />We need…..<br />We need…..<br />We need…..<br />K<br />We need…..<br />F<br />A<br />E<br />W...
Managed Extensibility Framework<br />The Managed Extensibility Framework (MEF) is a new library in Silverlight 4 for build...
MEF Basics…<br />An Application is built ofparts.<br />
Hello MEF in Silverlight<br />Demo<br />
MEF Basics…<br />Export it.<br />Import it.<br />Composeit.<br />
Export it.<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br />	public string Message {...
Import it.<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br />	[Import]<br />	public s...
Import it.<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br />	[Import(“HelloMEF.Messa...
Import it.<br />[Export(typeof(UserControl))]<br />public class MainPage: UserControl<br />{<br />	[ImportMany(typeof(User...
Compose it.<br />PartIntializer: “Compose yourself”<br /> public MainPage()<br /> {<br />InitializeComponent();<br />PartI...
Be different – Use metadata<br />
Where does the widget go?<br />Widget<br />Widget<br />
Export it - Metadata<br />[ExportMetadata(“Location”,Location.Top)]<br />[Export(typeof(UserControl))]<br />public class W...
Import it - Metadata<br />[Export(typeof(UserControl))]<br />public class MainPage: UserControl<br />{<br />	[ImportMany(t...
Have it your way! – Custom Exports<br />
Export it - Metadata<br />[ExportMetadata(“Location”,Location.Top)]<br />[Export(typeof(UserControl))]<br />public class W...
Customize it – Custom exports<br />[Widget(Location=Location.Top)]<br />public class Widget1 : UserControl<br />{<br />	pu...
Putting it all together<br />Demo<br />
Trim up your apps	break up your XAPs<br />Demo<br />
MEF and Prism<br />Ariel Ben-Horesh<br />arielb@sela.co.il<br />blogs.microsoft.co.il/blogs/arielbh<br />Developer<br />Se...
Introducing MEF-Prism integration<br />Our Goal : <br />Enable an existing Prism application to be further extended throug...
Introducing MEF-Prism integration<br />Prism application starts and loads up known modules.<br />Module Loader<br />
Introducing MEF-Prism integration<br />Prism application can load unknownplugins, by using MEF as an abstraction layer.<br...
Introducing MEF-Prism integration<br />Prism application can load unknownplugins, by using MEF as an abstraction layer.<br...
Introducing MEF-Prism integration<br />Prism application can load unknownplugins, by using MEF as an abstraction layer.<br...
Where can I get it?<br />MEF ships in Silverlight 4.0<br />Dynamic XAP support in SL 4.0 Toolkit<br />Silverlight 3.0 supp...
MEF Cross-platform(s)<br />Jackson Harper<br />jackson@novell.com<br />blog.MonoOnTheWeb.info<br />Software Engineer<br />...
Building Extensible RIAs with MEF
Upcoming SlideShare
Loading in...5
×

Building Extensible RIAs with MEF

1,375

Published on

PDC 2009 Talk on building extensible Silverlight 4.0 applications using the new managed extensibility framework.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,375
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
32
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • http://www.flickr.com/photos/dawnzy/3047246014/
  • http://www.flickr.com/photos/smcdevitt/3046557005/
  • http://www.flickr.com/photos/gangie/1189047644/
  • MESSAGING:New Library = just an assembly, a normal .dll, used by any .NET languageDynamically Composed = composition takes place at runtime and composition behavior differs depending on how it is configured.In making applications dynamically composed, MEF allows you to build systems that adhere to this “Open/Closed principle, in other words it makes it easy to design systems which can adapt to change.But MEF goes further than simply allow you to extend your own system, it provides a means to allow third parties to extend the application after it has been deployed.
  • There are really three concepts you need to understand with MEFExport It – Components (we call them Parts) provide capabilities to other parts called Exports. To Export you decorate your class with an Export attribute essentially saying, “Here I am providing this”Import It – To use the capabilities of another part, you Import it. To import your decorate a property on your part with an Import attribute which means “I need this”Compose It – The last step is putting the pieces together. The container (CompositionContainer) is responsible for that job. We’ll see how that works soon.
  • MESSAGING:Now in the case of Exports, exports are contracts a part offers to other parts. In the case of our DiscountRule, we are exporting ourself as an IRule. This is done very easily by decorating our class with an Export class and specifying that we would like to export ourselves specifically as an IRule (it’s important to note, that if you left out “typeof(IRule)”, the class would be exported as a DiscountRule instead (so other parts importing IRule would not find us)).Once again, very simple. Decorate with an Export attribute and MEF has all the information it needs for this specific part.
  • MESSAGING:In the case of our DiscountRule, we simply decorate our ILogger property with an Import attribute that specifies what type we need to import (this is because we could very well be importing a different type of contract than is satisfied directly (see the slide on Lazy for more info)). This is how simple it is. Decorate with an Import attribute and MEF has all the information it needs for this specific part.NOTES:This could also be done on a constructor that accepts an ILogger and uses the ImportingConstructor attribute.
  • MESSAGING:In the case of our DiscountRule, we simply decorate our ILogger property with an Import attribute that specifies what type we need to import (this is because we could very well be importing a different type of contract than is satisfied directly (see the slide on Lazy for more info)). This is how simple it is. Decorate with an Import attribute and MEF has all the information it needs for this specific part.NOTES:This could also be done on a constructor that accepts an ILogger and uses the ImportingConstructor attribute.
  • MESSAGING:Now this is good for a single import, but what about when I need to import many of a specific export? For example our RulesEngine imports a collection of rules. In this case we use an ImportManyAttribute on a collection.Note if we do ImportMany on a constuctor we must specify the [ImportMany] attribute explicitly.
  • MESSAGING:In the desktop there’s a bunch of work you need to do to get the composition going including creating a container and the catalogs. There’s also challenges particularly in XAML scenarios where the XAML runtime creates things like UserControls which don’t’ have access to the container. In Silverlight, we wanted to make it as simple as possible to get-going using MEF in your applications. There’s no need to create container or a catalog. We will automatically create a container for you and add to all the assemblies in the current XAP. All you need to do is call SatisfyImports on PartInitializer and we’ll take care of the rest.
  • MESSAGING:Now in the case of Exports, exports are contracts a part offers to other parts. In the case of our DiscountRule, we are exporting ourself as an IRule. This is done very easily by decorating our class with an Export class and specifying that we would like to export ourselves specifically as an IRule (it’s important to note, that if you left out “typeof(IRule)”, the class would be exported as a DiscountRule instead (so other parts importing IRule would not find us)).Once again, very simple. Decorate with an Export attribute and MEF has all the information it needs for this specific part.
  • MESSAGING:Now this is good for a single import, but what about when I need to import many of a specific export? For example our RulesEngine imports a collection of rules. In this case we use an ImportManyAttribute on a collection.Note if we do ImportMany on a constuctor we must specify the [ImportMany] attribute explicitly.
  • MESSAGING:Now in the case of Exports, exports are contracts a part offers to other parts. In the case of our DiscountRule, we are exporting ourself as an IRule. This is done very easily by decorating our class with an Export class and specifying that we would like to export ourselves specifically as an IRule (it’s important to note, that if you left out “typeof(IRule)”, the class would be exported as a DiscountRule instead (so other parts importing IRule would not find us)).Once again, very simple. Decorate with an Export attribute and MEF has all the information it needs for this specific part.
  • MESSAGING:Now in the case of Exports, exports are contracts a part offers to other parts. In the case of our DiscountRule, we are exporting ourself as an IRule. This is done very easily by decorating our class with an Export class and specifying that we would like to export ourselves specifically as an IRule (it’s important to note, that if you left out “typeof(IRule)”, the class would be exported as a DiscountRule instead (so other parts importing IRule would not find us)).Once again, very simple. Decorate with an Export attribute and MEF has all the information it needs for this specific part.
  • Transcript of "Building Extensible RIAs with MEF"

    1. 1.
    2. 2. Building Extensible Rich Internet Applications with the Managed Extensibility Framework<br />Glenn Block<br />Program Manager<br />Microsoft Corporation<br />
    3. 3. What we’ll cover<br />
    4. 4. RIA Extensions, add-ins, and plugins oh my!<br />
    5. 5. Extensibility implants<br />
    6. 6. Turning fat apps into slimmer apps<br />
    7. 7. Reality<br />RIA 1.0<br />
    8. 8. Reality<br />We need…..<br />We need…..<br />We need…..<br />We need…..<br />K<br />We need…..<br />F<br />A<br />E<br />We need…..<br />J<br />I<br />D<br />RIA 1.0<br />C<br />B<br />H<br />G<br />We need…..<br />We need…..<br />We need….<br />We need….<br />
    9. 9. Managed Extensibility Framework<br />The Managed Extensibility Framework (MEF) is a new library in Silverlight 4 for building applications that can be incrementally extended.<br />For customers<br />For you and your team <br />Always there, always ready<br />
    10. 10. MEF Basics…<br />An Application is built ofparts.<br />
    11. 11. Hello MEF in Silverlight<br />Demo<br />
    12. 12. MEF Basics…<br />Export it.<br />Import it.<br />Composeit.<br />
    13. 13. Export it.<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br /> public string Message {<br /> get{return(string) Button.Content;}<br /> set{Button.Content=value;}<br /> }<br />}<br />Widget1<br />UserControl<br />Export<br />
    14. 14. Import it.<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br /> [Import]<br /> public string Message {<br /> get{return(string) Button.Content;}<br /> set{Button.Content=value;}<br /> }<br />}<br />Widget1<br />String<br />Import<br />
    15. 15. Import it.<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br /> [Import(“HelloMEF.Message”)]<br /> public string Message {<br /> get{return(string) Button.Content;}<br /> set{Button.Content=value;}<br /> }<br />}<br />Widget1<br />“HelloMEF.Message”<br />Import<br />
    16. 16. Import it.<br />[Export(typeof(UserControl))]<br />public class MainPage: UserControl<br />{<br /> [ImportMany(typeof(UserControl))]<br /> public IEnumerable&lt;UserControl&gt; {<br />get;set;<br /> }<br />}<br />Main<br />Page<br />UserControl<br />ImportMany<br />
    17. 17. Compose it.<br />PartIntializer: “Compose yourself”<br /> public MainPage()<br /> {<br />InitializeComponent();<br />PartInitializer.SatisfyImports(this);<br /> }<br />MainPage<br />Compose<br />
    18. 18. Be different – Use metadata<br />
    19. 19. Where does the widget go?<br />Widget<br />Widget<br />
    20. 20. Export it - Metadata<br />[ExportMetadata(“Location”,Location.Top)]<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br /> public string Message {<br /> get{return(string) Button.Content;}<br /> set{Button.Content=value;}<br /> }<br />}<br />Widget1<br />Put me in the top<br />UserControl<br />Export<br />
    21. 21. Import it - Metadata<br />[Export(typeof(UserControl))]<br />public class MainPage: UserControl<br />{<br /> [ImportMany(typeof(UserControl))]<br /> public IEnumerable&lt;Lazy&lt;UserControl, IWidgetMetadata&gt; <br /> {<br />get;set;<br /> }<br />}<br />Main<br />Page<br />UserControl<br />ImportMany<br />
    22. 22. Have it your way! – Custom Exports<br />
    23. 23. Export it - Metadata<br />[ExportMetadata(“Location”,Location.Top)]<br />[Export(typeof(UserControl))]<br />public class Widget1 : UserControl<br />{<br /> public string Message {<br /> get{return(string) Button.Content;}<br /> set{Button.Content=value;}<br /> }<br />}<br />Widget1<br />Put me in the top<br />UserControl<br />Export<br />
    24. 24. Customize it – Custom exports<br />[Widget(Location=Location.Top)]<br />public class Widget1 : UserControl<br />{<br /> public string Message {<br /> get{return(string) Button.Content;}<br /> set{Button.Content=value;}<br /> }<br />}<br />Widget1<br />Put me in the top<br />UserControl<br />Export<br />
    25. 25. Putting it all together<br />Demo<br />
    26. 26. Trim up your apps break up your XAPs<br />Demo<br />
    27. 27. MEF and Prism<br />Ariel Ben-Horesh<br />arielb@sela.co.il<br />blogs.microsoft.co.il/blogs/arielbh<br />Developer<br />Sela Group<br />partner <br />
    28. 28. Introducing MEF-Prism integration<br />Our Goal : <br />Enable an existing Prism application to be further extended through MEF<br />Enabled MEF modules to be added dynamically on the fly.<br />Enable MEF discovered components to be registered in IoC container (Such as Unity). <br />
    29. 29. Introducing MEF-Prism integration<br />Prism application starts and loads up known modules.<br />Module Loader<br />
    30. 30. Introducing MEF-Prism integration<br />Prism application can load unknownplugins, by using MEF as an abstraction layer.<br />1. Plugins are located and added to a MEF catalog.<br />Server<br />
    31. 31. Introducing MEF-Prism integration<br />Prism application can load unknownplugins, by using MEF as an abstraction layer.<br />2. Plugins register dependencies with current IoC container.<br />Server<br />
    32. 32. Introducing MEF-Prism integration<br />Prism application can load unknownplugins, by using MEF as an abstraction layer.<br />3. Plugins are activated. Dependencies are injected.<br />Server<br />
    33. 33. Where can I get it?<br />MEF ships in Silverlight 4.0<br />Dynamic XAP support in SL 4.0 Toolkit<br />Silverlight 3.0 support on Codeplex<br />MEF source ships under MSPL<br />Learn more:<br /> Silverlight.net<br />MEF.Codeplex.com<br />MEFContrib.Codeplex.com – Prism/MEF<br /> blogs.msdn.com/gblock<br />
    34. 34. MEF Cross-platform(s)<br />Jackson Harper<br />jackson@novell.com<br />blog.MonoOnTheWeb.info<br />Software Engineer<br />Moonlight Project<br />partner <br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×