SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Intro to MEF with Silverlight




                            Jeremy Likness
                            Project Manager, Senior Consultant
                            jlikness@wintellect.com
                                                                   Copyright © 2011




consulting   training   design   debugging                       wintellect.com
what we do
    consulting     training    design     debugging

 who we are
   Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins –
   we pull out all the stops to help our customers achieve their goals through advanced
   software-based consulting and training solutions.

 how we do it                                           Training
                                                        •   On-site instructor-led training
   Consulting & Debugging                               •   Virtual instructor-led training
   •   Architecture, analysis, and design services      •   Devscovery conferences
   •   Full lifecycle custom software development
   •   Content creation                                 Design
   •   Project management                               •   User Experience Design
   •   Debugging & performance tuning                   •   Visual & Content Design
                                                        •   Video & Animation Production


consulting    training    design     debugging                                   wintellect.com
Agenda

 • Why MEF?
 • Discovery
 • Lifetime Management
 • Extensibility
 • Metadata
 • 10 Practical Reasons to use MEF
consulting   training   design   debugging   wintellect.com
Why MEF?

 • Misconception: Managed Extensibility
   Framework
 • Part of the framework
 • Discovery
 • Lifetime management
 • Extensibility
 • Metadata


consulting   training   design   debugging   wintellect.com
Welcome to the MEF Lab!

 • I admit I am a MEF addict!
 • You may be surprised by who has done
   MEF
 • Visual Studio 2010
 • 2010 Vancouver Olympics
 • Microsoft (Looking Glass)
 • SharePoint


consulting   training   design   debugging   wintellect.com
Discovery

 • Import: Contract and Demand
 • Export: Implementation and Supply
                        Look Ma! I
 • Part: Supply & Demand need 500
                      don’t
                                           constructor
                                            overloads!
                                 “I need something that implements IMessage”
 [Import]
 public IMessage MyMessenger { get; set; }

 [Export(typeof(IMessage))]
 public class SpecificMessenger : IMessage

                                     “I have something that implements IMessage”


consulting   training   design   debugging                            wintellect.com
Discovery: Catalogs

 •   Catalogs tell MEF where to find parts
 •   AssemblyCatalog: Current assembly
 •   TypeCatalog: List of types
 •   DeploymentCatalog: Silverlight XAP file
 •   AggregateCatalog: Composed of Multiple
     Catalogs



consulting   training   design   debugging   wintellect.com
Discovery: Container

 • The Container wraps the Catalog
 • The Container is responsible for
   Composition:
      – What parts exist?
         • What imports exist for a part?
         • What exports exist for a part?
 • This is the Discovery step
 • In Silverlight specifically the
   “CompositionInitializer” handles containers
consulting   training   design   debugging   wintellect.com
Discovery: Catalogs & Containers

                                                     Wraps parts in the current XAP


                                    Look Ma! No
 var deploymentCatalog = new DeploymentCatalog();

 var container = new
                                   Bootstrapper!
                             CompositionContainer(deploymentCatalog);

 container.ComposeParts(this);

                                      Using the parts in the container, find all
                                       parts in the current class, then satisfy
                                      all imports with corresponding exports
                                                  (“Composition”)



consulting   training   design   debugging                               wintellect.com
Demo
   Hello, MEF!




consulting   training   design   debugging   wintellect.com
CompositionInitializer
 • Notice that composition happens “explicitly” with
   the composition call
 • What about XAML objects? These are created by
   the XAML parser, not MEF
 • How do you share a container across the
   application?
 • CompositionInitializer solves this problem by
   creating a default, global container
 • Must be high level: classes that use this cannot
   export themselves!
consulting   training   design   debugging   wintellect.com
Stable Composition

 •   Guarantees imports are satisfied
 •   Works throughout the entire hierarchy
 •   Helps keep plug-ins “honest”
 •   What about multiple plug-ins?




consulting   training   design   debugging   wintellect.com
ImportMany

 • Allows multiple implementations
 • Stable composition will reject invalid
   exports




consulting   training   design   debugging   wintellect.com
Demo
   ImportMany




consulting   training   design   debugging   wintellect.com
Lifetime Management

 • What’s wrong with Singletons?
      – Change the behavior of the class simply to modify the
        lifetime of the class (poor separation of concerns)
      – Tough to test and mock
      – Often abused and create dependencies
 • PartCreationPolicy
 • RequiredCreationPolicy
 • Factory


consulting   training   design   debugging            wintellect.com
Demo
   MVVM & Lifetime Management




consulting   training   design   debugging   wintellect.com
Bonus: Design and Test with MEF

 • Use composition for the run time
 • Use design prefixes for design-time
      – Composition will fail in the designer due to a different
        runtime for Cider, but this is fine if you follow the
        pattern described
      – Use mock utilities that can mock an object for the
         interface
 • In test, you can export a different
   implementation or simply set mocks directly

consulting   training   design   debugging              wintellect.com
Extensibility

 • Most inversion of control/dependency
   injection frameworks help wire what you
   know (bootstrapper)
 • MEF provides for what you don’t know
 • For non-extensible applications, this still
   allows for modularity
 • For extensible applications, this allows for
   plug-ins

consulting   training   design   debugging   wintellect.com
Extensibility: Dynamic XAP Files
 • First, use an AggregateCatalog to allow multiple XAP files
 • The DeploymentCatalog allows asynchronous downloads
   for XAP files
 • Use a new Silverlight Application to create satellite
   assemblies
 • CompositionHost will override the default container
 • CopyLocal = false for duplicate references
 • AllowRecomposition
 • ObservableCollection



consulting   training   design   debugging           wintellect.com
Demo
   Dynamic XAP File




consulting   training   design   debugging   wintellect.com
Metadata

 • Add additional information about an export
 • Filter exports without invoking/creating
   them
 • Allows for plug-ins to only be generated in
   context
 • Strongly typed
 • Uses the pattern Lazy<T,TMetadata>


consulting   training   design   debugging   wintellect.com
Demo
   Metadata with Jounce




consulting   training   design   debugging   wintellect.com
10 Practical Reasons to Use MEF
 1.  It’s out of the box
 2.  It provides Inversion of Control/Discovery
 3.  It gives you lifetime management
 4.  It can easily manage application wide configuration
 5.  It provides factories that resolve their own dependencies
 6.  It allows for multiple implementations of the same contract (pipeline
     and chain of responsibility)
 7. It filters with strongly-typed metadata
 8. It dynamically loads modules and extends existing applications
 9. It provides for modularity and clean separation of concerns
 10. It is completely customizable to address your specific needs (i.e.
     ExportFactory)


consulting   training   design   debugging                      wintellect.com
Questions?




                            Jeremy Likness
                            Project Manager, Senior Consultant
                            jlikness@wintellect.com



consulting   training   design   debugging                       wintellect.com

Weitere ähnliche Inhalte

Was ist angesagt?

10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Molieremfrancis
 
Building an Eclipse plugin to recommend changes to developers
Building an Eclipse plugin to recommend changes to developersBuilding an Eclipse plugin to recommend changes to developers
Building an Eclipse plugin to recommend changes to developerskim.mens
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008rajivmordani
 
Dependency injection via annotations v1.0
Dependency injection via annotations v1.0Dependency injection via annotations v1.0
Dependency injection via annotations v1.0Jerry Kurian
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity frameworkMaxim Shaptala
 
Natural Language Classifier - Handbook (IBM)
Natural Language Classifier - Handbook (IBM)Natural Language Classifier - Handbook (IBM)
Natural Language Classifier - Handbook (IBM)Davi Couto
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software EngineerSean Coates
 
Drupal 8 Involvement with Promet Source
Drupal 8 Involvement with Promet SourceDrupal 8 Involvement with Promet Source
Drupal 8 Involvement with Promet SourcePromet Source
 
Most Useful Design Patterns
Most Useful Design PatternsMost Useful Design Patterns
Most Useful Design PatternsSteven Smith
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing SoftwareSteven Smith
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1tactqa
 
Get your Project back in Shape!
Get your Project back in Shape!Get your Project back in Shape!
Get your Project back in Shape!Joachim Tuchel
 
software technology benchmarking
software  technology benchmarkingsoftware  technology benchmarking
software technology benchmarkingMallikarjuna G D
 
[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration[English version] JavaFX and Web Integration
[English version] JavaFX and Web IntegrationKazuchika Sekiya
 

Was ist angesagt? (19)

10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
 
Building an Eclipse plugin to recommend changes to developers
Building an Eclipse plugin to recommend changes to developersBuilding an Eclipse plugin to recommend changes to developers
Building an Eclipse plugin to recommend changes to developers
 
Java Framework comparison
Java Framework comparisonJava Framework comparison
Java Framework comparison
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
 
Dependency injection via annotations v1.0
Dependency injection via annotations v1.0Dependency injection via annotations v1.0
Dependency injection via annotations v1.0
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity framework
 
Natural Language Classifier - Handbook (IBM)
Natural Language Classifier - Handbook (IBM)Natural Language Classifier - Handbook (IBM)
Natural Language Classifier - Handbook (IBM)
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer
 
Drupal 8 Involvement with Promet Source
Drupal 8 Involvement with Promet SourceDrupal 8 Involvement with Promet Source
Drupal 8 Involvement with Promet Source
 
Most Useful Design Patterns
Most Useful Design PatternsMost Useful Design Patterns
Most Useful Design Patterns
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing Software
 
Basic Selenium Training
Basic Selenium TrainingBasic Selenium Training
Basic Selenium Training
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1
 
Get your Project back in Shape!
Get your Project back in Shape!Get your Project back in Shape!
Get your Project back in Shape!
 
jp06_bossola
jp06_bossolajp06_bossola
jp06_bossola
 
05 managing transactions
05   managing transactions05   managing transactions
05 managing transactions
 
slide to delete
slide to deleteslide to delete
slide to delete
 
software technology benchmarking
software  technology benchmarkingsoftware  technology benchmarking
software technology benchmarking
 
[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration
 

Ähnlich wie Introduction to the Managed Extensibility Framework in Silverlight

Building extensible application using MEF
Building extensible application using MEFBuilding extensible application using MEF
Building extensible application using MEFRonak Thakkar
 
Acing application lifecycle management in SharePoint
Acing application lifecycle management in SharePointAcing application lifecycle management in SharePoint
Acing application lifecycle management in SharePointJeremy Thake
 
Sitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helixSitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helixPeter Nazarov
 
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...Edureka!
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Phil Leggetter
 
A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012Imaginet
 
Full Stack DevOps - Ready To Go
Full Stack DevOps - Ready To GoFull Stack DevOps - Ready To Go
Full Stack DevOps - Ready To GoKallex
 
Intro to modern web technology
Intro to modern web technologyIntro to modern web technology
Intro to modern web technologyChris Love
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Jeremy Likness
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous IntegrationXPDays
 
Selenium web driver_2.0_presentation
Selenium web driver_2.0_presentationSelenium web driver_2.0_presentation
Selenium web driver_2.0_presentationsayhi2sudarshan
 
Wintellect - Windows 8 for the Silverlight and WPF Developer
Wintellect   - Windows 8 for the Silverlight and WPF DeveloperWintellect   - Windows 8 for the Silverlight and WPF Developer
Wintellect - Windows 8 for the Silverlight and WPF DeveloperJeremy Likness
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--devaltsav
 
Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02Kdeepapal Mishra
 
Software Engineering - chp8- deployment
Software Engineering - chp8- deploymentSoftware Engineering - chp8- deployment
Software Engineering - chp8- deploymentLilia Sfaxi
 
ALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudJeremy Likness
 
Accelerate Sitecore DevOps on Microsoft Azure
Accelerate Sitecore DevOps on Microsoft AzureAccelerate Sitecore DevOps on Microsoft Azure
Accelerate Sitecore DevOps on Microsoft AzurePerficient, Inc.
 
The Nuxeo Way: leveraging open source to build a world-class ECM platform
The Nuxeo Way: leveraging open source to build a world-class ECM platformThe Nuxeo Way: leveraging open source to build a world-class ECM platform
The Nuxeo Way: leveraging open source to build a world-class ECM platformNuxeo
 

Ähnlich wie Introduction to the Managed Extensibility Framework in Silverlight (20)

Building extensible application using MEF
Building extensible application using MEFBuilding extensible application using MEF
Building extensible application using MEF
 
Acing application lifecycle management in SharePoint
Acing application lifecycle management in SharePointAcing application lifecycle management in SharePoint
Acing application lifecycle management in SharePoint
 
Sitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helixSitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helix
 
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
 
A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012
 
Full Stack DevOps - Ready To Go
Full Stack DevOps - Ready To GoFull Stack DevOps - Ready To Go
Full Stack DevOps - Ready To Go
 
Intro to modern web technology
Intro to modern web technologyIntro to modern web technology
Intro to modern web technology
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
Selenium web driver_2.0_presentation
Selenium web driver_2.0_presentationSelenium web driver_2.0_presentation
Selenium web driver_2.0_presentation
 
Wintellect - Windows 8 for the Silverlight and WPF Developer
Wintellect   - Windows 8 for the Silverlight and WPF DeveloperWintellect   - Windows 8 for the Silverlight and WPF Developer
Wintellect - Windows 8 for the Silverlight and WPF Developer
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--dev
 
Net Beans
Net BeansNet Beans
Net Beans
 
Net Beans
Net BeansNet Beans
Net Beans
 
Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02
 
Software Engineering - chp8- deployment
Software Engineering - chp8- deploymentSoftware Engineering - chp8- deployment
Software Engineering - chp8- deployment
 
ALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the Cloud
 
Accelerate Sitecore DevOps on Microsoft Azure
Accelerate Sitecore DevOps on Microsoft AzureAccelerate Sitecore DevOps on Microsoft Azure
Accelerate Sitecore DevOps on Microsoft Azure
 
The Nuxeo Way: leveraging open source to build a world-class ECM platform
The Nuxeo Way: leveraging open source to build a world-class ECM platformThe Nuxeo Way: leveraging open source to build a world-class ECM platform
The Nuxeo Way: leveraging open source to build a world-class ECM platform
 

Kürzlich hochgeladen

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Kürzlich hochgeladen (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

Introduction to the Managed Extensibility Framework in Silverlight

  • 1. Intro to MEF with Silverlight Jeremy Likness Project Manager, Senior Consultant jlikness@wintellect.com Copyright © 2011 consulting training design debugging wintellect.com
  • 2. what we do consulting training design debugging who we are Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops to help our customers achieve their goals through advanced software-based consulting and training solutions. how we do it Training • On-site instructor-led training Consulting & Debugging • Virtual instructor-led training • Architecture, analysis, and design services • Devscovery conferences • Full lifecycle custom software development • Content creation Design • Project management • User Experience Design • Debugging & performance tuning • Visual & Content Design • Video & Animation Production consulting training design debugging wintellect.com
  • 3. Agenda • Why MEF? • Discovery • Lifetime Management • Extensibility • Metadata • 10 Practical Reasons to use MEF consulting training design debugging wintellect.com
  • 4. Why MEF? • Misconception: Managed Extensibility Framework • Part of the framework • Discovery • Lifetime management • Extensibility • Metadata consulting training design debugging wintellect.com
  • 5. Welcome to the MEF Lab! • I admit I am a MEF addict! • You may be surprised by who has done MEF • Visual Studio 2010 • 2010 Vancouver Olympics • Microsoft (Looking Glass) • SharePoint consulting training design debugging wintellect.com
  • 6. Discovery • Import: Contract and Demand • Export: Implementation and Supply Look Ma! I • Part: Supply & Demand need 500 don’t constructor overloads! “I need something that implements IMessage” [Import] public IMessage MyMessenger { get; set; } [Export(typeof(IMessage))] public class SpecificMessenger : IMessage “I have something that implements IMessage” consulting training design debugging wintellect.com
  • 7. Discovery: Catalogs • Catalogs tell MEF where to find parts • AssemblyCatalog: Current assembly • TypeCatalog: List of types • DeploymentCatalog: Silverlight XAP file • AggregateCatalog: Composed of Multiple Catalogs consulting training design debugging wintellect.com
  • 8. Discovery: Container • The Container wraps the Catalog • The Container is responsible for Composition: – What parts exist? • What imports exist for a part? • What exports exist for a part? • This is the Discovery step • In Silverlight specifically the “CompositionInitializer” handles containers consulting training design debugging wintellect.com
  • 9. Discovery: Catalogs & Containers Wraps parts in the current XAP Look Ma! No var deploymentCatalog = new DeploymentCatalog(); var container = new Bootstrapper! CompositionContainer(deploymentCatalog); container.ComposeParts(this); Using the parts in the container, find all parts in the current class, then satisfy all imports with corresponding exports (“Composition”) consulting training design debugging wintellect.com
  • 10. Demo Hello, MEF! consulting training design debugging wintellect.com
  • 11. CompositionInitializer • Notice that composition happens “explicitly” with the composition call • What about XAML objects? These are created by the XAML parser, not MEF • How do you share a container across the application? • CompositionInitializer solves this problem by creating a default, global container • Must be high level: classes that use this cannot export themselves! consulting training design debugging wintellect.com
  • 12. Stable Composition • Guarantees imports are satisfied • Works throughout the entire hierarchy • Helps keep plug-ins “honest” • What about multiple plug-ins? consulting training design debugging wintellect.com
  • 13. ImportMany • Allows multiple implementations • Stable composition will reject invalid exports consulting training design debugging wintellect.com
  • 14. Demo ImportMany consulting training design debugging wintellect.com
  • 15. Lifetime Management • What’s wrong with Singletons? – Change the behavior of the class simply to modify the lifetime of the class (poor separation of concerns) – Tough to test and mock – Often abused and create dependencies • PartCreationPolicy • RequiredCreationPolicy • Factory consulting training design debugging wintellect.com
  • 16. Demo MVVM & Lifetime Management consulting training design debugging wintellect.com
  • 17. Bonus: Design and Test with MEF • Use composition for the run time • Use design prefixes for design-time – Composition will fail in the designer due to a different runtime for Cider, but this is fine if you follow the pattern described – Use mock utilities that can mock an object for the interface • In test, you can export a different implementation or simply set mocks directly consulting training design debugging wintellect.com
  • 18. Extensibility • Most inversion of control/dependency injection frameworks help wire what you know (bootstrapper) • MEF provides for what you don’t know • For non-extensible applications, this still allows for modularity • For extensible applications, this allows for plug-ins consulting training design debugging wintellect.com
  • 19. Extensibility: Dynamic XAP Files • First, use an AggregateCatalog to allow multiple XAP files • The DeploymentCatalog allows asynchronous downloads for XAP files • Use a new Silverlight Application to create satellite assemblies • CompositionHost will override the default container • CopyLocal = false for duplicate references • AllowRecomposition • ObservableCollection consulting training design debugging wintellect.com
  • 20. Demo Dynamic XAP File consulting training design debugging wintellect.com
  • 21. Metadata • Add additional information about an export • Filter exports without invoking/creating them • Allows for plug-ins to only be generated in context • Strongly typed • Uses the pattern Lazy<T,TMetadata> consulting training design debugging wintellect.com
  • 22. Demo Metadata with Jounce consulting training design debugging wintellect.com
  • 23. 10 Practical Reasons to Use MEF 1. It’s out of the box 2. It provides Inversion of Control/Discovery 3. It gives you lifetime management 4. It can easily manage application wide configuration 5. It provides factories that resolve their own dependencies 6. It allows for multiple implementations of the same contract (pipeline and chain of responsibility) 7. It filters with strongly-typed metadata 8. It dynamically loads modules and extends existing applications 9. It provides for modularity and clean separation of concerns 10. It is completely customizable to address your specific needs (i.e. ExportFactory) consulting training design debugging wintellect.com
  • 24. Questions? Jeremy Likness Project Manager, Senior Consultant jlikness@wintellect.com consulting training design debugging wintellect.com

Hinweis der Redaktion

  1. I’ve been talking about MEF for awhile. At many of my talks, I’m stopped with “Jeremy, hold on, you’re showing us advanced uses of MEF. But why do I even want to use MEF in the first? What is it exactly that MEF does?”
  2. Discovery is what most people are looking to do when they implement Inversion of Control and Dependency Injection. There are many ways to do discovery from factories and service locators to bootstrappers and IoC containers. MEF provides a very simple and straightforward way to handle discovery.
  3. Copy the Hello MEF. Convert to a ListBox. Change Text to an array and then set the items source.
  4. Creation policies are run always once, when the imports are satisfied. Factory is unique in that it provides a means for creating new instances, and works independent of the part creation policy.
  5. This demo is a full-fledged MEF/MVVM solution. It shows not only the lifetime management concept, but how MEF works with MVVM to drive Silverlight applications. It also shows design-time support with MEF.
  6. Copy the import many. Add an aggregate catalog and use that in the container and introduce CompositionHost. Disable the button on click. Change the text to an observable collection, then add the new project with the export. Show that the button click does NOT actually pull the new export. Then add AllowRecomposition and show it working.
  7. Jounce is a framework that provides specific guidance for MVVM with MEF.
  8. If time permits, go back to some of the case studies and discuss how they worked with MEF.