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 { getset; }
        
//WorkItemStore 
        public WorkItemStore WorkItemStore { getset; }
        
        
//Get Project Info 
        public ICommonStructureService CommonStructureService { getset; }
        
//VersionControlServer 
        public VersionControlServer VersionControlServer { getset; }
        
//User and Permission
        public IGroupSecurityService GroupSecurityService { getset; }
        
//Build
        public IBuildServer BuildServer { getset; }
        
        
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 { }

           
        }
}

posted on 2009-09-18 13:54  Ruiz  阅读(1520)  评论(0编辑  收藏  举报

导航