Sunday, January 31, 2010

Add-In Pipeline Development.

Recently I was on a project related to developing an extensible application.
.Net Framework provide many programming models for creating an extensible applications , some of them are Managed Extensibility Framework, Visual Studio Tools for Applications and Add-in Pipeline Development.

Visual Studio Tools for Application and Addin-Pipeline development leverages the Add-in development model whereas MEF uses the Dipendency Injection to extend application through extension compostion. The project I worked on was related to Visual Studio Tools for Application development. Major part of pipeline development for Host and Add-In is automated in VSTA and pipeline components are automatically managed by VSTA.

Other then VSTA we can develop the pipline for Add-In framework to work in our project from scratch. Extensible application are called Host that uses the service of Add-In's to extend themself. Add-In's are activated in Host application and extends the features or services of the Host application. So , there are two parts ,first the Add-In that provides the services to the Host and the Host application that consumes the services of Add-In.

The communication between the host and the Add-In is carried out by the pipeline that has to be created manually , although tools are available to achive this (VsPipeLine Builder). The pipeline is implemented by using the types in the System.AddIn, System.AddIn.Hosting, System.AddIn.Pipeline, and System.AddIn.Contract namespaces. The Host and Add-In are at the two end of the pipeline. Host application exposes the Object model that Add-In will use to extend the Host. So, both the Host and Add-In should share a comman Object model .
This is achived by a Contract , an interace that contains the method that both Add-In and Host will use . Contract is the abstraction between Host and Add-In through which both exchange 'types' for communication. Types that are communicated between both of them should be Contracts or Serializable .

Lets see the components of the pipeline between Host and the Add-In. We have seen the Contract that is the centeral component of the pipeline. Next there are abstract classes or Interfaces that defines the views of object model used to communicate ( As defined by Contract ), as seen by Add-In and the Host. Both these views are identical , having same members but differs in Attributes applied to them (we will see them later) .

These views represent object types and methods used to communicate as seen by the Add-In and Host. Now we have the Contract that define the protocol of communication between the Add-In and Host, we have the views that Add-In and Host have of Object Model.



The components that are missing are the components responsible for the conversion of the view to contract and contract to view.These component are called the Adapters , Host side adapter and Add-In side adapter. Lets see the communication from Add-In to Host . First the Add-In view of types are converted into contracts to pass to Host by Add-In side adapter .After the contracts are made by the Add-In side adapter , the host side adapter takes on and converts these contracts to the Host side view .In this way the serialized types are passed to the Host by Add-in.
That was the theory part , in next blog we will see the practical implementation.

No comments:

Post a Comment