Get TFS Model and TFS Service Using TFS SDK
To get TFS Model/services, please add these assemblies to reference http://www.cnblogs.com/Ruiz/archive/2009/09/18/1569416.html
Following code shows how to get the service
public class TFSModal
{
//TFS Model
public TeamFoundationServer TFServer { get; set; }
//WorkItemStore
public WorkItemStore WorkItemStore { get; set; }
//Get Project Info
public ICommonStructureService CommonStructureService { get; set; }
//VersionControlServer
public VersionControlServer VersionControlServer { get; set; }
//User and Permission
public IGroupSecurityService GroupSecurityService { get; set; }
//Build
public IBuildServer BuildServer { get; set; }
public TFSModal(string serverName)
{
try
{
TFServer = TeamFoundationServerFactory.GetServer(serverName);
WorkItemStore = (WorkItemStore)TFServer.GetService(typeof(WorkItemStore));
VersionControlServer = (VersionControlServer)TFServer.GetService(typeof(VersionControlServer));
CommonStructureService = (ICommonStructureService)TFServer.GetService(typeof(ICommonStructureService));
GroupSecurityService = (IGroupSecurityService)TFServer.GetService(typeof(IGroupSecurityService));
BuildServer = (IBuildServer)TFServer.GetService(typeof(IBuildServer));
}
catch { }
}
}
{
//TFS Model
public TeamFoundationServer TFServer { get; set; }
//WorkItemStore
public WorkItemStore WorkItemStore { get; set; }
//Get Project Info
public ICommonStructureService CommonStructureService { get; set; }
//VersionControlServer
public VersionControlServer VersionControlServer { get; set; }
//User and Permission
public IGroupSecurityService GroupSecurityService { get; set; }
//Build
public IBuildServer BuildServer { get; set; }
public TFSModal(string serverName)
{
try
{
TFServer = TeamFoundationServerFactory.GetServer(serverName);
WorkItemStore = (WorkItemStore)TFServer.GetService(typeof(WorkItemStore));
VersionControlServer = (VersionControlServer)TFServer.GetService(typeof(VersionControlServer));
CommonStructureService = (ICommonStructureService)TFServer.GetService(typeof(ICommonStructureService));
GroupSecurityService = (IGroupSecurityService)TFServer.GetService(typeof(IGroupSecurityService));
BuildServer = (IBuildServer)TFServer.GetService(typeof(IBuildServer));
}
catch { }
}
}