如何使用 TFS API 从 TFS 获取集合
请参阅此处了解更多详情。这是关于 TFS 的最佳资源之一。
private TfsConfigurationServer configurationServer;
configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri);
public IList<KeyValuePair<Guid, String>> GetCollections()
{
//ApplicationLogger.Log("Entered into GetCollections() : ");
var collectionList = new List<KeyValuePair<Guid, String>>();
try
{
configurationServer.Authenticate();
ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
new[] { CatalogResourceTypes.ProjectCollection },
false,
CatalogQueryOptions.None);
foreach (CatalogNode collectionNode in collectionNodes)
{
var collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
TfsTeamProjectCollection teamProjectCollection =
configurationServer.GetTeamProjectCollection(collectionId);
if (teamProjectCollection == null)
continue;
collectionList.Add(new KeyValuePair<Guid, String>(collectionId, teamProjectCollection.Name));
}
}
catch (Exception e)
{
ApplicationLogger.Log(e);
}
return collectionList;
}
列表中每个返回的键值对都包含集合 guid 和集合名称