Exemplo n.º 1
0
        /// <summary>
        /// Connects to the TFS server.
        /// </summary>
        public void Connect()
        {
            configurationServer = new TfsConfigurationServer(ServerUri, System.Net.CredentialCache.DefaultCredentials);

            // 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);

                // Find the requested team project collection
                if (teamProjectCollection.Name.ToUpper(CultureInfo.InvariantCulture).EndsWith(this.TeamProjectCollectionName.ToUpper(CultureInfo.InvariantCulture), StringComparison.Ordinal))
                {
                    SourceControl = (VersionControlServer)teamProjectCollection.GetService(typeof(VersionControlServer));

                    this.TeamProjects = new ReadOnlyCollection <TeamProject>(SourceControl.GetAllTeamProjects(false));

                    break; // We got what we want, now exit the loop
                }
            }
        }