This project is read-only.

Going from the Blank Contract Sample to a Working Solution

This page is designed to help walk you through all the steps needed to start using this samples as a starting point for your project: Sample- Blank Pipeline Project. We'll use a simple calculator contract as a sample.

When you open the solution you'll see the Contracts.cs file with these contents:
/// Copyright (c) Microsoft Corporation.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.AddIn.Contract;
using PipelineHints;


//You should change the assembly name and default namespace for this project before you use it. 
namespace Sample.Blank.Contracts
{
   
}


The first thing you should do is update the assembly name and default namespace for this project. To do this right click on the project and click on properties. From there click on the "Application" tab. In this case we'll change both the "Default namespace" and the "Assembly name" to "Sample.Calculator.Contracts". You can also rename the project by right-clicking on the project name and hitting "Rename".
ChangingAssemblyName.jpg

Once you've updated the project settings you can start adding your contracts. In this case we'll add an ICalculatorContract interface and end up with this:
/// Copyright (c) Microsoft Corporation.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.AddIn.Contract;
using PipelineHints;


namespace Sample.Calculator.Contracts
{
    [System.AddIn.Pipeline.AddInContract]
    public interface ICalculatorContract : IContract
    {
        double Add(double a, double b);
        double Subtract(double a, double b);
        double Multiply(double a, double b);
        double Divide(double a, double b);
    }
}


Since the ICalculatorContract type represents an add-in, and not simply a type that is exchanged between the host and the add-in, you need to apply the System.AddIn.Pipeline.AddInContract to identify the contract as something that can be activated. Once you've added the above code just need to compile the contract and it will be ready for use by the Pipeline Builder.

If you examine the output placed in the AddInView and HostView projects you'll notice that the tool will automatically remove the "Contract" suffix from the name of all types and will drop the ".Contracts" suffix from the default namespace. You'll probably want to change the name of the assemblies as well. You can do this using the SegmentAssemblyName attribute.

Last edited Jan 12, 2008 at 12:09 AM by JesseKaplan, version 2

Comments

No comments yet.