How to create an adapter for the TFS Integration Platform - Part IV: IProvider

Note: This post is part of a series and you can find the rest of the parts in the series index.

_IProvider_ is the first class we will look at implementing for both adapters (WI and VC) as it provides the core information for the platform to talk to our adapter. The first thing your provider needs is the _ProviderDescriptionAttribute_, which has three properties: ID, Name, and Version.

[ProviderDescription("{7F3F91B2-758A-4B3C-BBA8-CE34AE1D48EE}", "SharePoint TIP Adapter - Version Control", "1.0.0.0")]

The ID must be unique, and you will need to record it somewhere as it is used in the platform's configuration. The name and version can help users, though I have not seen them used in practice (they might appear in future or different tools).

The only method in the provider is the _GetService()_ method, which the platform uses to retrieve implementations of the interfaces/classes you will build later. In other words, this method allows the platform to request a class that implements a specific interface:

object IServiceProvider.GetService(Type serviceType)
{
    TraceManager.TraceInformation("WSSVC:Adapter:GetService - {0}", serviceType);

    if (serviceType == typeof(IAnalysisProvider))
    {
        if (analysisProvider == null)
        {
            analysisProvider = new SharePointVCAnalysisProvider();
        }
        return analysisProvider;
    }

    if (serviceType == typeof(IMigrationProvider))
    {
        if (migrationProvider == null)
        {
            migrationProvider = new SharePointVCMigrationProvider();
        }
        return migrationProvider;
    }

    if (serviceType == typeof(IServerPathTranslationService))
    {
        if (trans**a**lationProvider == null)
        {
            trans**a**lationProvider = new SharePointVCAdapterTranslation();
        }
        return trans**a**lationProvider;
    }

    return null;
}

Above is the implementation from the SharePoint VC adapter. The WI adapter follows the same pattern, except it does not include the server path translation service at the end.

Power Tip: Using Visual Studio 2010’s new “Generation from usage” feature makes this stage of development much easier.