This project is read-only.

Create and Deploy your own MEF Component to extend Zen4Sync



Overview

Among all the Activities available in a Test Scenario is the MEF Component Execution.
This Activity is the execution of a C# DLL you wrote.

The only mandatory step to take is to implement an interface provided by Zen4Sync.
This interface contains a single method (called Execute) which will be called when Zen4Sync executes the Activity that relies on the MEF Component.

Zen4Sync extension capabilities rely on the Managed Extensibility Framework.

Thus the Zen4Sync possibilities are endless, since you can execute you own code as part of a Test Scenario.

This page explains how to create and deploy your own Zen4Sync MEF Component.

Set up your Zen4Sync MEF Component Project

All you need to do to set up your Zen4Sync MEF Component Project is:
  1. Create a Class Library Project in Visual Studio,
  2. Add references to the System.ComponentModel.Composition assembly and the Zen4Sync MEF Component DLL,
  3. Create a Class that implements the DLL referenced in step 2.

The DLL resulting from the build of your Class Library Project is the MEF Component you'll deploy in Zen4Sync.

The 2 sections below provide you with two ways of achieving the 3 steps listed above.

If you use Visual Studio 2010, we highly recommend that you go for the Project Template solution as it is less error-prone and will save you time.
Nevertheless, if you are not using Visual Studio 2010 you can still set up your Zen4Sync MEF Component project by following the manual solution.

Using the Visual Studio 2010 Project Template

To save you some time and get straight to the coding step, Zen4Sync provides a VSIX Package which will add a Zen4Sync MEF Component Project Template in the New Project dialog box of Visual Studio.

In order for Visual Studio 2010 to show you the Zen4Sync MEF Component Project Template in the available templates, you'll need to:
249948

The new Project Template is now part of Visual Studio 2010.

Now the Project Template is installed, you're ready to create a new Zen4Sync MEF Component Project.
In Visual Studio, go to File > New > Project... and select the Zen4Sync MEF Component Template under the Visual C# Templates

249954

Name the project and click OK.

You should see the following in the Solution Explorer:
  • References to Zen4SyncMefContract and System.ComponentModel.Composition in the Project References
  • A Class named Zen4SyncMefComponent where you'll have to write your code

249953

You can now skip to the coding section of this page.

Using a manually created Project

All you need to do to set up your Zen4Sync MEF Component Project is:
  • Create a Class Library Project in Visual Studio
  • Add references to the System.ComponentModel.Composition assembly and the Zen4Sync MEF Component DLL:
    1. Download the Zen4Sync MEF Component Creation Resources
    2. Extract the Zen4SyncMefContract.dll contained in the downloaded archive on your hard drive
    3. In the Solution Explorer of Visual Studio, right-click on References, then click on Add Reference...
    4. Add references to the downloaded Zen4SyncMefContract.dll file and to the System.ComponentModel.Composition assembly
  • Add a new Class to your Project and modify its declaration so that it looks like the following:
// Notice the Export attribute and the Zen4SyncMefContract.IZen4SyncMefContract implementation
[Export(typeof(Zen4SyncMefContract.IZen4SyncMefContract))]
public class ClassName : Zen4SyncMefContract.IZen4SyncMefContract
  • Add the Execute method as part of the interface implementation:
// You'll have to add the following using statement: using System.Xml.Linq; 
public void Execute(XElement activityData, XElement contextData)
{

}
You can now skip to the coding section of this page.

Code your MEF Component

You'll have to write your code in the Execute method body.

The two parameters correspond to the XML inserted when creating the Activity based on the MEF Component.
For further details on these two pieces of XML, see the page about creating a MEF Execution Activity.

Deploy your Zen4Sync MEF Component

A Zen4Sync MEF Component has to be deployed on a Test Sever (referred to as the Target Test Server in the rest of this page).

“Deployed” means copied to the local hard drive of the Target Test Server and declared into the Zen4SyncRepository database.

To deploy your Zen4Sync MEF Component, execute the following steps:
  • Build the Class Library Project of your MEF Component
  • Copy the obtained DLL and paste it in a directory on the local hard drive of the Target Test Server
    • Note: The DLL must be the only Zen4Sync MEF Component DLL present in the directory where it's been copied.
  • Download the Script allowing to deploy a MEF Component, fill it as explained in the comments of the script and execute it against the Zen4SyncRepository database.

Last edited Jun 17, 2011 at 10:43 AM by Christophe_, version 50

Comments

No comments yet.