1 / 27

MEF & Silverlight 4: Extensible A pplications

MEF & Silverlight 4: Extensible A pplications. Applicazioni estensibili impiegando MEF e Silverlight 4. Davide Zordan – MVP Silverlight, Silverlight Insider. Cos’è MEF. Perché MEF. MEF: concetti fondamentali. Esportazione di una classe:. [Export ]

meryle
Download Presentation

MEF & Silverlight 4: Extensible A pplications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MEF & Silverlight 4: ExtensibleApplications Applicazioni estensibili impiegando MEF e Silverlight 4 • Davide Zordan – MVP Silverlight, Silverlight Insider

  2. www.xedotnet.org

  3. Cos’è MEF www.xedotnet.org

  4. Perché MEF www.xedotnet.org

  5. MEF: concetti fondamentali www.xedotnet.org

  6. Esportazione di una classe: [Export] public partialclassShellView: UserControl { public ShellView() { InitializeComponent(); } } www.xedotnet.org

  7. Esportazione tramite proprietà: public classLoggerpart { [Export] public ILogLogger { get{ returnLogManager.GetLogger("Logger"); } } } www.xedotnet.org

  8. Importazione tramite proprieta' e campi [Export] public classViewFactory { [Import] public ShellViewshellView{ get; set; } } www.xedotnet.org

  9. Importazione tramite costruttori [Export] public classViewFactory { [ImportingConstructor] public ViewFactory(ShellViewshellView) { } } www.xedotnet.org

  10. Composizione Composizione mediante il CompositionInitializer: CompositionInitializer.SatisfyImports(this); www.xedotnet.org

  11. PartCreationPolicy [PartCreationPolicy(CreationPolicy.NonShared)] [Export(typeof(IShellView))] public partialclassShellView: UserControl, IShellView { public ShellView() { } } www.xedotnet.org

  12. Esportazioni multiple [Export] public classViewFactory { [ImportMany] IEnumerable<IView> Views { get; set; } } [Export(typeof(IView))] public partialclassShellView: UserControl, IView { } public interfaceIView{} www.xedotnet.org

  13. Attributi personalizzati di esportazione [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public classExportMainPageVMAttribute : ExportAttribute { public ExportMainPageVMAttribute(): base(typeof(ViewModelBase)) { } } www.xedotnet.org

  14. Utilizzo public partial class MainPageView : UserControl { public MainPageView() { InitializeComponent(); CompositionInitializer.SatisfyImports(this); this.DataContext = mainPageViewModel; } [ImportMainPageVMAttribute] public object mainPageViewModel { get; set; } } www.xedotnet.org

  15. Esportazioni multiple e Metadata public classSimpleMEFProvider { [Export("SimpleText")] [ExportMetadata("Index",0)] public string aSimpleTextProvider { get { return "This is a simple Text MEF Imported"; } } [Export("SimpleText")] [ExportMetadata("Index",1)] public string anotherSimpleTextProvider { get { return "This is another simple Text MEF Imported"; } } } www.xedotnet.org

  16. Import Metadata public partialclassMainPage : UserControl { public MainPage() { InitializeComponent(); CompositionInitializer.SatisfyImports(this); } //Multiple Exports detected: use ImportMany [ImportMany("SimpleText")] public IEnumerable<Lazy<string,IMetadataContent>> textProperty { get; set; } //Used to retrieve the value of the Metadata Exported by MEF public interfaceIMetadataContent { int Index { get; } } } www.xedotnet.org

  17. Demo 1: Simple Composition Ok OK, show me the samples www.xedotnet.org

  18. Demo 1: Export, Import, Compose! Demo 1: EXPORT, IMPORT, COMPOSE! www.xedotnet.org

  19. Demo 2: Export multipli Demo 2: Export multipli www.xedotnet.org

  20. Demo 3: Export multipli Demo 3: Export metadata www.xedotnet.org

  21. Demo 4: Simple MEF-MVVM Demo 4: simplemef-mvvm www.xedotnet.org

  22. Demo 5: Simple MEF-MVVM Demo 5: attributi custom www.xedotnet.org

  23. Demo 6: Export Factory Demo 6: export factory www.xedotnet.org

  24. Demo 7: MEF & (PRISM) EventAggregator Demo 7: MEF & (prism) eventaggregator www.xedotnet.org

  25. Demo 8: MEF & DeploymentCatalog Demo 8: MEF & Deployment Catalog www.xedotnet.org

  26. Riepilogo www.xedotnet.org

  27. Link How to reach me  • http://www.davidezordan.net/blog • info@davidezordan.net • http://silverlightexperts.net • http://twitter.com/davidezordan www.xedotnet.org

More Related