Software Experts
Call Us: +40 770 613 713 | EU
17th Jan 2015 | by: cetus

Overview

MEF (Managed Extensibility Framework) was used for the plugin implementation. A description of how the plugin system works is given below with information on both the MEF and our own implementation, for more information on MEF go to the official documentation site or the MEF Community Site. Our implementation of the plugins is slightly different from the one given in the official documentation, in order to avoid adding unnecessary components. Obviously, the concepts and principles of MEF are still followed in our implementation.

Plugin Components

As of yet there is no separate module in our solution for plugins, it has not been necessary as MEF provides everything that’s needed. Our plugin scheme is composed of a plugin container and the plugins themselves.

The plugin container has two main roles:

  1. to provide the contract for plugins to be built on
  2. to instantiate and expose the plugin use outside the container

The contract of a plugin consists of the service contract and the metadata. The service contract exposes the properties and methods of the plugin while the metadata is used to expose specific data.

In the case of storage providers the plugin contract is IStorageProvider which exposes operations such as Initialize, Authorize and others.

The metadata for storage providers is IStorageProviderMetadata which exposes two fields:

A plugin has to export both the service contract and the metadata (in the case of the metadata each field has to be exported individually):

Assembling Plugin Components

The assembling of the plugin components is done in the plugin container which has to display the wanted plugins by importing their contracts:

The plugin container assembles the plugins components by use of a CompositionContainer:

The CompositionContainer is pointed towards the components (or their location) through catalogs:

  1. The plugin container which has to be loaded with the plugins (this request is made through the _plugins field with the ImportMany attribute)
  2. The plugins themselves

If no problem appears then the _plugins field should be loaded with the available plugins from the current directory whose names follow the given pattern.

In order to add more plugins no changes need be done to the container, they will be discovered and loaded automatically.

Share This Post

About the Author: cetus

Leave a Reply

Your email address will not be published.