TFS 2010 API By Example: Getting Links to Web Access

In Team Foundation Server 2010 web access is installed by default.  Therefore you can now happily create links to web access resources and know that there is somewhere that you can point a web browser to to find more information.  However what is less well known is that there is a handy service available in the TFS 2010 object model to help you create the links – the TswaClientHyperlinkService.

Take a quick look at the MSDN documentation for more information, but a quick look at the methods available in IntelliSense shows you some very useful methods including:

Using the link service is very easy if you are used to calling other TFS services in code.  For example:

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(projectCollectionUrl));
TswaClientHyperlinkService service = tfs.GetService<TswaClientHyperlinkService>();

if (service != null)
    // View Changeset
    int changesetId = 1;
    Uri viewChangesetUrl = service.GetChangesetDetailsUrl(changesetId);
    Console.WriteLine("Changeset " + changesetId + ": " + viewChangesetUrl.AbsoluteUri);

    // View annotate on a file
    Uri annotateFileUrl = service.GetAnnotateSourceControlItemUrl("$/path/to/file/myfile.txt",
    Console.WriteLine("Annotate: {0}", annotateFileUrl.AbsoluteUri);



Creative Commons License
This blog is licensed under a Creative Commons License.