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.
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
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!