Click here to Skip to main content
15,887,434 members
Articles / Programming Languages / C#
Article

TFS: Check Out - Get Latest

Rate me:
Please Sign up or sign in to vote.
3.78/5 (3 votes)
8 Sep 2007CPOL 62.9K   381   9   8
Addin for Visual Studio 2005 to prompt user to get the latest version before checking out a file for edit

Introduction

This project allows TFS users the ability to get the latest version before editing a file upon check-out. Based on the code started here, this project adds two things. One is the prompt - It asks the user if she/he wants to get the latest version (not always do they want to do this - They may be editing an earlier version on purpose). The second change is that the original requires the developer to modify the devenv.exe.config file to add the TFS server information. This project detects the currently connected server/project and uses that information.

Using the Code

The important changes come in the TFSAccess class. Notice below that the server is detected and when a change occurs, that is also detected.

C#
internal TFSAccess(DTE2 applicationObject)
{
  _TFSExt = applicationObject.GetObject
		("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") 
		as TeamFoundationServerExt;
  if (_TFSExt != null)
  {
    if (_TFSExt.ActiveProjectContext.ProjectName == null)
    {
      _TFSExt.ProjectContextChanged += 
		new EventHandler(this._TFSExt_ProjectContextChanged);
    }
    else
    {
      _previousDomainName = _TFSExt.ActiveProjectContext.DomainName;
      Connect();
    }
  }
}

private void _TFSExt_ProjectContextChanged(object sender, EventArgs e)
{
  if (_TFSExt != null && _TFSExt.ActiveProjectContext != null && 
			_TFSExt.ActiveProjectContext.DomainUri != null)
  {
    if (_previousDomainName != _TFSExt.ActiveProjectContext.DomainName)
    {
      Connect();
      this.OnConnectToTFS(new EventArgs());
    }
  }
  _previousDomainName = _TFSExt.ActiveProjectContext.DomainName;
}

History

  • 8th September, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Gabriel McAdams is a longtime .NET developer. He has specialized in ASP.NET and Web Services. Gabriel mostly develops using: C# ASP.NET Web Applications and Web Services SQL Server 2005/2008 - but over the course of over 10 years as a developer has used a lot of other technologies!

Comments and Discussions

 
GeneralCannot check-in file which were replaced to latest version by plugin Pin
TRVQ224-Jul-09 0:06
TRVQ224-Jul-09 0:06 
GeneralRe: Cannot check-in file which were replaced to latest version by plugin Pin
ghmcadams24-Jul-09 5:29
ghmcadams24-Jul-09 5:29 
GeneralRe: Cannot check-in file which were replaced to latest version by plugin Pin
TRVQ227-Jul-09 23:19
TRVQ227-Jul-09 23:19 
Questionerror? Pin
ColinBashBash9-Sep-08 11:28
ColinBashBash9-Sep-08 11:28 
AnswerRe: error? Pin
ghmcadams10-Sep-08 8:18
ghmcadams10-Sep-08 8:18 
GeneralRe: error? Pin
ColinBashBash29-Sep-08 10:39
ColinBashBash29-Sep-08 10:39 
sorry that i never got back to you on this. I'm stupid. we have VSS, but we don't have TFS, so of course it won't work. fun fun.
GeneralUnable to Connect TFS Pin
Thulasi Rao26-May-08 19:44
Thulasi Rao26-May-08 19:44 
GeneralRe: Unable to Connect TFS Pin
ghmcadams10-Sep-08 8:20
ghmcadams10-Sep-08 8:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.