CSharp examples for Microsoft.TeamFoundation.Client:TfsConfigurationServer
Get Team Projects
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.ObjectModel; using System.Collections.Generic; using System;//ww w.j a v a 2s . c om using Microsoft.TeamFoundation.Framework.Common; using Microsoft.TeamFoundation.Framework.Client; using Microsoft.TeamFoundation.Client; public class Main{ public static List<string> GetTeamProjects(string _uri) { List<string> _teamProjects = new List<string>(); TfsConfigurationServer configServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(_uri)); ReadOnlyCollection<CatalogNode> collectionNodes = configServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); foreach (CatalogNode collectionNode in collectionNodes) { Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = configServer.GetTeamProjectCollection(collectionId); ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren( new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); foreach (CatalogNode projectNode in projectNodes) { _teamProjects.Add(projectNode.Resource.DisplayName); } } return _teamProjects; } }