Present by Andie Saizan, MCP

Slides:



Advertisements
Similar presentations
MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Advertisements

INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Implementing Autodesk Inventor in Your Company MA405-1
Managed Extensibility Framework Georges
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
Technical Architectures
Visual Web Information Extraction With Lixto Robert Baumgartner Sergio Flesca Georg Gottlob.
Chapter 22 Object-Oriented Design
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Welcome to Drupal Crash course - Gartheeban Ganeshapillai.
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
Ihr Logo Data Explorer - A data profiling tool. Your Logo Agenda  Introduction  Existing System  Limitations of Existing System  Proposed Solution.
Design Patterns.
Christopher Jeffers August 2012
Module 8 Configuring and Securing SharePoint Services and Service Applications.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
@DNNCon Don’t forget to include #DNNCon in your tweets! Effective Unit Testing for DNN James McKee Solutions Developer / Enterprise
Tradepoint Enterprise – Sneak Peek at Version 3.0 Power Point Template.
Visual Studio 2010 and.NET Framework 4 Training Workshop.
Refactoring for Testability (or how I learned to stop worrying and love failing tests) Presented by Aaron Evans.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL315.
Advanced Object-oriented Design Patterns Creational Design Patterns.
SPI NIGHTLIES Alex Hodgkins. SPI nightlies  Build and test various software projects each night  Provide a nightlies summary page that displays all.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
Dependency Injection with Guice Technion – Institute of Technology Author: Gal Lalouche - Technion 2016 ©
© Copyright SELA software & Education Labs Ltd Baruch Hirsch St.Bnei Brak Israel
Understanding Dependency Injection… and those pesky containers Miguel A. Castro Architect -
Vladimir Milev New Venture Software Sharing Code between WPF and Universal Apps.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Modularization of Geant4 Dynamic loading of modules Configurable build using CMake Pere Mato Witek Pokorski
Theming in GNUstep ● What is it for? ● It seems there have been three groups calling for theming in GNUstep. ● Some don't like the standard NeXTstep look.
Microsoft Foundation Classes MFC
Lesson # 9 HP UCMDB 8.0 Essentials
Abstract Factory Pattern
Chapter 5:Design Patterns
Self Healing and Dynamic Construction Framework:
Mark Seemann - Dependency Injection in .NET
Best Practices and Architecture
Behavioral Design Patterns
Design Patterns.
Distribution and components
Did your feature got in, out or planned?
Managed Extensibility Framework
Magento Technical Guidelines Eugene Shakhsuvarov, Software Magento
Chapter 25: Architecture and Product Lines
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Northbound API Dan Shmidt | January 2017
AVG 24th 2015 ADVANCED c# - part 1.
Chapter 2: The Linux System Part 2
MSIS 670 Object-Oriented Software Engineering
Dependency Injection with MEF and Unity
Analysis models and design models
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
An Introduction to Software Architecture
On the notion of Variability in Software Product Lines
Leveraging ColdSpring To Make Better Applications
Designing For Testability
European conference.
Software Engineering and Architecture
Ponder policy toolkit Jovana Balkoski, Rashid Mijumbi
Concepts in ASP.NET Core App
ASP.NET Core Middleware Fundamentals
Presentation transcript:

Present by Andie Saizan, MCP Get addicted to MEF and use it in your architecture Managed Extensibility Framework (MEF) Present by Andie Saizan, MCP

It’s part of .Net! MEF is a component of .NET Framework aiming to create lightweight, extensible applications. It aims to allow .NET application developers to discover and use extensions with no configuration required. It also aims to allow developers encapsulate code easily and avoid fragile hard dependencies. Furthermore, it aims to allow extensions to be reused across applications. MEF was introduced as a part of .NET 4.0

Dependency Injection (DI)? Inversion of Control (IoC)? IoC is a design pattern with the goal of reducing awareness of concrete implementations from application framework code and giving more control to the domain specific components of your application. Dependency injection is a pattern used to create instances of classes that other classes rely on without knowing at compile time which implementation will be used to provide that functionality. IoC can utilize DI because a mechanism is needed in order to create the components providing the specific functionality.

How easy is it to implement? Reference System.ComponentModel.Composition Use the Export Attribute on classes you want to make injectable Use the Import, ImportMany, or the ImportingContructor in the classes where you want to inject To inject create a Composition Container and a Catalog This is generally done with a bootstrap class that loads during startup. Catalogs can be created from an assembly contained in the project, from a directory that contains assemblies, or a combination of both.

Lifetime Management CreationPolicy Enumeration found in System Lifetime Management CreationPolicy Enumeration found in System.ComponentModel.Composition Member name Description Any Specifies that the CompositionContainer will use the most appropriate CreationPolicy for the part given the current context. This is the default CreationPolicy. By default, CompositionContainer will use Shared, unless the ComposablePart or importer requests NonShared. NonShared Specifies that a new non-shared instance of the associated ComposablePart will be created by the CompositionContainer for every requestor. Shared Specifies that a single shared instance of the associated ComposablePart will be created by the CompositionContainer and shared by all requestors. (Singleton)

Export Factory This works with the non-shared partial creation policy and allows the injection of an ExportFactory<T>, which is used within the injected class to create instances of T. This is used when you have the need to create multiple instances of an object, that contain DI objects, shared and/or non-shared.

ImportMany Provider Pattern Create an IProcessor with multiple implementations. Create a ProcessorProvider and use MEF to Import all implementations of IProcessor. In the Provide method you query you Processors that meet the criteria specified to provide a Processor. Very useful in WPF applications when working with Controls and Views. A common pattern in WPF applications is to have a region for some functionality, and then page through multiple controls within that region. For example, a wizard might occupy the main region of the page but actually use four different controls for each of four different steps in the wizard. MEF makes it easy to handle this pattern using ImportMany. I can ask for an IWizard and then retrieve a list of controls that satisfy the interface.

The Power Of Metadata Think lazy loading. MEF allows you to supply strongly-typed metadata for your exports. Metadata can provide initialization information, routing information, and even priority information. You can create and inherit from MetadataAttributes and Export classes with the metadata, allowing you to use Lazy Loading. This allows object not to be initialized until they are used. You can also access the metadata without initializing the object. This can be very beneficial in large scale WPF applications with lots of Controls/Views. All the controls can be imported into a View manager and accesses or navigated to as need by evaluating the metadata.

Extensibility, Extensibility, Extensibility! MEF is unique in that it is designed specifically for extensibility. Many Dependency Injection/Inversion of Control solutions are designed to help you wire up what you know - "I have this instance, map it to this interface." MEF is designed to help you wire up what you don't know. It is extensible by nature and contains features such as stable composition that ensure your application can safely extend in real-time. You can build an application using MEF. While the application is running you can build a plugin, drop it into the target directory, and the application is able to pull in the new plugin in real-time without restarting.

Modularity Modularity is most beneficial in WPF and Windows Store Apps. MEF allows for modularity by allowing you to separate functionality into different modules and load them dynamically as needed. Imagine a large application that has ten menu items, but users typically may only go into one. Instead of loading everything , MEF allows you to split your applications into modules that load on demand. Only when the user needs a piece of functionality, will the application load the extension and make it available. This allows them to get up and running faster and conserves resources by only supplying what is needed.

Unit Testing With MEF Because of dependency injection, unit testing applications can be done with ease and you have options. You can create and compose a container with fake or mocked classes You can test individual parts of you application and mock the data for the imports without composition

Why I love MEF and why you should to! It’s part of the .Net Library. No add-ins, no plugins, it’s just there already. It handles both Dependency Injection and IoC, with minimal code. Lifetime management with Partial Creation Policy Handle application configuration data with ease Can use Factories for dependency resolution. ImportMany, which is one of my favorites because it works to beautifully with the provider pattern. It offers the ability for strongly typed metadata and lazy loading. It make extending applications done with ease. Modularity! MEF makes applications light weight, only loading what is needed. MEF is configurable and it plays well with others such as Unity and Prism. It’s easily Unit Testable an Mockable

Want me to show you the code? Email @ andie.saizan@outlook.com