Glenn Block Blogs/msdn.com/gblock @gblock MEF in the real world Glenn Block Blogs/msdn.com/gblock @gblock.

Slides:



Advertisements
Similar presentations
A guided tour of MEF in Silverlight 4 Mike Taulty Microsoft UK
Advertisements

Tips, Tricks, and Techniques for Building Killer Silverlight Apps Jeff Prosise
Build-Deploy-Test with Visual Studio Lab Management 2010 Pieter Gheysens Visual Studio ALM MVP – Sparkles User Group Lead VISUG (
DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
ASP.NET 3.5 Mike Ormond Developer & Platform Group Microsoft Ltd
HTML5 That’s what you need to know today Ingo Rammer, thinktecture
& Silverlight, Windows Phone 7, Windows Azure, jQuery, OData and RIA Services. Shaken, not stirred. Kevin
Connect with life Praveen Srvatsa Director | AsthraSoft Consulting Microsoft Regional Director, Bangalore Microsoft MVP, ASP.NET.
Windows Forms in Visual Studio 2005: An Overview Saurabh Pant Program Manager Microsoft Corporation.
Parallel Programming in.NET 4.0 Tasks and Threading Ingo Rammer, thinktecture
DYNAMICS CRM AS AN xRM DEVELOPMENT PLATFORM Jim Novak Solution Architect Celedon Partners, LLC
Change the Rules Silverlight 4 – A Guided Tour of MEF Mike Taulty, Microsoft UK
Total Workstation Lockdown: Your Action Plan Jeremy Moskowitz, Group Policy MVP Chief Propeller-Head: GPanswers.com Founder: PolicyPak Software (policypak.com)
Rudi Grobler Session Code: WUX205.
NuGet in Depth Making Open Source Suck Less at Microsoft Scott Hanselman
Getting Started with Caliburn.Micro and Windows Phone 7 Gary Ewan Park Twitter: Blog:
Parallel Programming in.NET 4.0 Tasks and Threading Ingo Rammer, thinktecture
Windows Phone MVVM and Unit Testing Step by Step Andy Wigley Windows Phone Development MVP, Mobile Software Consultant APPA Mundi Ltd WPH208.
Nikhil Kothari Software Architect Microsoft Corporation Session Code: WUX312.
Windows Azure for IT Pros Kurt CLAEYS (TSP Windows Azure, Microsoft EMEA)
Designing Enterprise Corporate Web Sites using SharePoint 2010 Paul Stubbs Technical Evangelist Microsoft.
ISV for credit management software. setting the goal ●Modernizing existing product to fit the needs of customers ●Migration from monolithic application.
Forthcoming SQL Azure Services: SQL Azure Data Sync & SQL Azure Reporting Mark Scurrell Lead Program Manager Microsoft.
David Ollason Lead Program Manager Microsoft Corporation SESSION CODE: UNC322 The New Communicator “14” Platform.
Service Manager 2010 Real Life Example: The coffee workflow Mike Resseler & Alexandre Verkinderen Infront Consulting Group.
Building Robust, Maintainable Coded UI Tests with Visual Studio 2010 Brian Keller Sr. Technical Evangelist – Visual Studio ALM
To OData or Not to OData Chris Eargle kodefuguru.com.
Building Complete Web Application Using ASP.NET 3.5 & Visual Studio 2008 Omar Khan Group Program Manager Visual Studio.
Ian Griffiths Principle Interact Software Ltd. Brian A. Randell Senior Consultant MCW Technologies DEV302.
GrapeCity Build Experiences with Enterprise-level Tools and Solutions
Introduction ITEC 420.
In Windows 8 Store Applications
How to be a SharePoint Developer
All about Ashley GmbH COMMUNICATION PARTNERS Partner overview.
Introduction to ASP.NET Core
Make your app a native part of Office with Add-ins
InGenius Connector Enterprise Microsoft Dynamics CRM
5/15/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
MIX 09 6/5/2018 9:14 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Dive into Application Lifecycle Management with Visual Studio 2010
9/4/2018 5:28 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Automating AD Administration with Windows PowerShell
What’s New in the Lync Client SDK 9/8/2018 8:15 AM
ASP.NET 3.5 Mike Ormond Developer & Platform Group Microsoft Ltd
TechEd /13/2018 9:06 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Rock Hard: C++ Evolving
DotnetConf 11/14/2018 3:27 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE.
Microsoft Build /15/2018 6:28 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Developer Patterns to Integrate Silverlight 4.0 with SharePoint 2010
Integrating Security Roles into Microsoft Silverlight Applications
SharePoint & jQuery: Better Together
Author: Joe ‘The CRM Chap’ Griffin Website: crmchap.co.uk
Tech Ed North America /1/2018 4:27 PM Required Slide
MIX 09 12/8/2018 4:33 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Authoring for Microsoft Silverlight 4 with Microsoft Expression Blend
A walkthrough Corey Hynes | HynesITe, Inc
Unlocking the secrets of REST with WCF
Tech·Ed North America /17/2019 1:47 AM
WCF Web API, HTTP your way
Microsoft SharePoint Conference 2009 Jon Flanders
Chris Eargle kodefuguru.com
What is Visual Studio Code?
Building Business Applications in LightSwitch
Tech Ed North America /12/2019 6:45 AM Required Slide
SharePoint 2010 Wizardry with Silverlight
6/20/2019 1:09 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Opalis System Center Integration Packs Deep Dive
.NET Framework V3.5+ & RESTful web services
Tech Ed North America /6/2019 2:07 PM Required Slide
Presentation transcript:

Glenn Block Blogs/msdn.com/gblock @gblock MEF in the real world Glenn Block Blogs/msdn.com/gblock @gblock

Who am I? Program Manager on the MEF team for V1 Drove the design of many key features Worked with many customers building systems on MEF Truly believe that MEF can dramatically improve your development

How can we get from this?

To this

And from here

To here

MEF quick glance Main Window 3. Compose 1. Import 2. Export

Export it. Import it. Compose it. MEF Basics… There are really three concepts you need to understand with MEF Export 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.

Choose your flavor! MEF .NET 4.0 MEF Silverlight 4 MEF .NET 3.5 MEF on Mono MEF on Moonlight PocketMEF http://www.flickr.com/photos/avlxyz/3579578625/

What we learned / recommend MEF is NOT a UI framework You don’t have to build entirely on MEF / you can use it for existing systems Don’t expose the container directly, use services Create custom attributes Use Inherited Export for invisibility Use property exports for legacy

What people like Simple to use Powerful/Flexible Solves the problem Extensible MEF on Codeplex / MSPL http://www.flickr.com/photos/thetruthabout/2842830409/

What some people don’t like* Hard to debug Hard to know what to extend / how to extend Hard to use in ASP.NET .NET Platform not compositionally friendly Versioning issues Attribute noise Lack of AOP support No support for open generics

Products/projects using MEF Visual Studio 2010 RavenDB Caliburn Jounce ILSpy Glimpse Prism

Provisioner OCS2007 R2 and Lync 2010 Implementations [MetadataAttribute] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class ExportWithContextAttribute : ExportAttribute { public object Context { get; set; } public ExportWithContextAttribute(Type contractType, object context) : base(contractType) { this.Context = context; } } public interface IProvisioner { // Methods List<ApplicationPool> GetApplicationPool(string applicationName); bool CreateApplicationPool(ApplicationPool applicationPool); void UpdateApplicationPool(ApplicationPool applicationPool); bool DeleteApplicationPool(string applicationName); bool DeleteApplicationPool(ApplicationPool applicationPool); bool ApplicationPoolExists(string applicationName); List<Contact> GetContacts(string applicationName); Contact GetContact(string applicationName, string uri); bool AddContact(ApplicationPool applicationPool, Contact contact); bool UpdateContact(ApplicationPool applicationPool, Contact contact); bool DeleteContact(ApplicationPool applicationPool, Contact contact); string GetApplicationPoolGRUU(ApplicationPool applicationPool); } OCS2007 R2 and Lync 2010 Implementations [ExportWithContext(typeof(IProvisioner), CommunicationsServerVersion.LyncServer2010)] public class LyncPool : IProvisioner, IPartImportsSatisfiedNotification { } [ExportWithContext(typeof(IProvisioner), CommunicationsServerVersion.OCS2007R2)] public class OCSFrontEnd: IProvisioner, IPartImportsSatisfiedNotification { }

Contact Center for Microsoft Lync 2010 Modular, integrated software suite that provides sophisticated contact center functionality on the Microsoft© Lync™ Server 2010 platform. Receives Customer Interaction Solutions Magazine’s 2010 Product of the Year Award

Where we use MEF prairieFyre uses MEF in: Our Ignite client application Our Lync Provisioner service As time goes on our use of MEF continues to grow. MEF has significant roles in our v.Next planning. MEF allows us to decouple components in our applications/services and enables a great extensibility story.

Ignite The call center agent client application MVVM with WPF

What MEF does for Ignite Ignite’s MVVM framework was written with MEF at the base. MEF resolves Views and ViewModels MEF resolves dependencies that Views and ViewModels require for core functionality. Communications to our real time streams. Event Aggregator By building the base on MEF for Views, ViewModels and Event Aggregator we now have a rich plugin extensibility model available for v.Next.

BaseViewModel public class BaseViewModel<TViewModel> : IViewModel, INotifyPropertyChanged, IPartImportsSatisfiedNotification { // Composed Dependencies from MEF [Import] public IEventAggregator Events { get; set; } public BaseViewModel() { if (DesignHelpers.DesignMode == false) ApplicationHost.Container.SatisfyImportsOnce(this); } public virtual void OnImportsSatisfied() { Events.Subscribe(this); } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { OnPropertyChanged(this, propertyName); } protected void OnPropertyChanged(object sender, string propertyName) { OnPropertyChanged(sender, new PropertyChangedEventArgs(propertyName)); } protected void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (PropertyChanged != null) PropertyChanged(sender, e); } }

Provisioner Service Configures OCS 2007 or Lync based on what the customer has installed. OCS 2007 Enterprise Config Provisioner Service Lync 2010

What MEF does for the Provisioner The Provisioner needs to support configuring OCS 2007 and Lync 2010 and future Lync releases. We decoupled the service in 3 parts. Model Audit Controller IProvisioner By detecting if the service is running against OCS 2007 or Lync we use MEF to resolve which implementation of IProvisioner to audit against. MEF helps us going forward for swapping out IProvisioner implementations as Lync evolves.

Provisioner OCS2007 R2 and Lync 2010 Implementations [MetadataAttribute] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class ExportWithContextAttribute : ExportAttribute { public object Context { get; set; } public ExportWithContextAttribute(Type contractType, object context) : base(contractType) { this.Context = context; } } public interface IProvisioner { // Methods List<ApplicationPool> GetApplicationPool(string applicationName); bool CreateApplicationPool(ApplicationPool applicationPool); void UpdateApplicationPool(ApplicationPool applicationPool); bool DeleteApplicationPool(string applicationName); bool DeleteApplicationPool(ApplicationPool applicationPool); bool ApplicationPoolExists(string applicationName); List<Contact> GetContacts(string applicationName); Contact GetContact(string applicationName, string uri); bool AddContact(ApplicationPool applicationPool, Contact contact); bool UpdateContact(ApplicationPool applicationPool, Contact contact); bool DeleteContact(ApplicationPool applicationPool, Contact contact); string GetApplicationPoolGRUU(ApplicationPool applicationPool); } OCS2007 R2 and Lync 2010 Implementations [ExportWithContext(typeof(IProvisioner), CommunicationsServerVersion.LyncServer2010)] public class LyncPool : IProvisioner, IPartImportsSatisfiedNotification { } [ExportWithContext(typeof(IProvisioner), CommunicationsServerVersion.OCS2007R2)] public class OCSFrontEnd: IProvisioner, IPartImportsSatisfiedNotification { }

Our Future MEF Use We plan to increase our use of MEF in both Ignite and the Lync Provisioner service. Planning has begun to use MEF as the base for new products we are working on now to release to market soon.

What’s next for MEF? http://www.amazon.com/gp/product/images/0453009212/sr=8-2/qid=1266438061/ref=dp_image_text_0

Stay up to date with MSDN Belux Register for our newsletters and stay up to date: http://www.msdn-newsletters.be Technical updates Event announcements and registration Top downloads Follow our blog http://blogs.msdn.com/belux Join us on Facebook http://www.facebook.com/msdnbe http://www.facebook.com/msdnbelux LinkedIn: http://linkd.in/msdnbelux/ Twitter: @msdnbelux Download MSDN/TechNet Desktop Gadget http://bit.ly/msdntngadget Please keep this slide

TechDays 2011 On-Demand Watch this session on-demand via Channel9 http://channel9.msdn.com/belux Download to your favorite MP3 or video player Get access to slides and recommended resources by the speakers

THANK YOU