C# TFS SDK 2013获取给定团队项目中的团队名称

C# TFS SDK 2013获取给定团队项目中的团队名称,c#,tfs,tfs-sdk,C#,Tfs,Tfs Sdk,您好,有人能帮我获取给定团队项目中的所有团队吗 当前代码获取所有团队项目(从) public void getTeamProjects() { TfsConfigurationServer configServer=TfsConfigurationServerFactory.GetConfigurationServer(\u uri); ReadOnlyCollection collectionNodes=configServer.CatalogNode.QueryChildren( 新[]{C

您好,有人能帮我获取给定团队项目中的所有团队吗

当前代码获取所有团队项目(从)

public void getTeamProjects()
{
TfsConfigurationServer configServer=TfsConfigurationServerFactory.GetConfigurationServer(\u uri);
ReadOnlyCollection collectionNodes=configServer.CatalogNode.QueryChildren(
新[]{CatalogResourceTypes.ProjectCollection},
错误,目录查询选项。无);
foreach(collectionNodes中的CatalogNode collectionNode)
{
Guid collectionId=新Guid(collectionNode.Resource.Properties[“InstanceId”]);
TfsTeamProjectCollection teamProjectCollection=configServer.GetTeamProjectCollection(collectionId);
Console.WriteLine(“Collection:+teamProjectCollection.Name”);
ReadOnlyCollection projectNodes=collectionNode.QueryChildren(
新[]{CatalogResourceTypes.TeamProject},
错误,目录查询选项。无);
foreach(项目节点中的CatalogNode项目节点)
{
Console.WriteLine(“团队项目:+projectNode.Resource.DisplayName”);
//如何访问每个projectNode的团队名称。
}
}
控制台。写入线(“完成”);
Console.ReadKey();
} 

当前在控制台上,它正在正确打印所有团队项目。我希望能够访问每个团队项目中的团队名称。

检查codeplex上ALM Rangers提供的TFS团队工具的源代码

this.teamService=this.teamProjectCollection.GetService();
公开名单小组()
{
var teams=this.teamService.QueryTeams(this.projectInfo.Uri);
return(从团队中的t选择t.Name).ToList();
}
    public void getTeamProjects()
    {
        TfsConfigurationServer configServer = TfsConfigurationServerFactory.GetConfigurationServer(_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);
            Console.WriteLine("Collection: " + teamProjectCollection.Name);

           ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
           new[] { CatalogResourceTypes.TeamProject },
           false, CatalogQueryOptions.None);

           foreach (CatalogNode projectNode in projectNodes)
           {
               Console.WriteLine("Team Project: " + projectNode.Resource.DisplayName);
               // How do I access the Team names of each projectNode.
           }

        }

        Console.WriteLine("Finished");
        Console.ReadKey();
    } 
this.teamService = this.teamProjectCollection.GetService<TfsTeamService>();

public List<string> ListTeams()
{
    var teams = this.teamService.QueryTeams(this.projectInfo.Uri);
    return (from t in teams select t.Name).ToList();
}