Get Team Project Collections - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:ICollection

Description

Get Team Project Collections

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System;/*from w  ww.j a  va 2s .  c o m*/
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Client;

public class Main{
        public static List<string> GetTeamProjectCollections(string _uri)
        {
            List<string> _collections = 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);

                _collections.Add(teamProjectCollection.CatalogNode.Resource.DisplayName);

            }

            return _collections;
        }
}

Related Tutorials