为什么在程序中使用 Microsoft.TeamFoundation.Client 和 Microsoft.TeamFo

本文关键字:Microsoft TeamFoundation Client TeamFo 程序 为什么 | 更新日期: 2023-09-27 18:30:34

在连接到 TFS 服务器的 TFS C# 程序中,我们对同一类客户端使用下面列出的两个命名空间。

使用 Microsoft.TeamFoundation.Client;

使用 Microsoft.TeamFoundation.Framework.Client;

我的问题是为什么从两个不同的命名空间使用相同的类客户端?

对于下面列出的程序(从这里开始)

using System;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Client;
namespace TfsApplication
{
    class Program
    {
        static void Main(String[] args)
        {
            // Connect to Team Foundation Server
            //     Server is the name of the server that is running the application tier for Team Foundation.
            //     Port is the port that Team Foundation uses. The default port is 8080.
            //     VDir is the virtual path to the Team Foundation application. The default path is tfs.
            Uri tfsUri = (args.Length < 1) ? 
                new Uri("http://Server:Port/VDir") : new Uri(args[0]);
            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);
            // Get the catalog of team project collections
            ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
                new[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);
            // List the team project collections
            foreach (CatalogNode collectionNode in collectionNodes)
            {
                // Use the InstanceId property to get the team project collection
                Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
                // Print the name of the team project collection
                Console.WriteLine("Collection: " + teamProjectCollection.Name);
                // Get a catalog of team projects for the collection
                ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
                    new[] { CatalogResourceTypes.TeamProject },
                    false, CatalogQueryOptions.None);
                // List the team projects in the collection
                foreach (CatalogNode projectNode in projectNodes)
                {
                    Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
                }
            }
        }
    }
}

为什么在程序中使用 Microsoft.TeamFoundation.Client 和 Microsoft.TeamFo

Microsoft.TeamFoundation.Framework.Client命名空间用于CatalogNode类。

此外,TfsConfigurationServer,TfsTeamProjectCollection,TfsConfigurationServerFactory等也存在于Microsoft.TeamFoundation.Client命名空间中。