public override void EnsureAuthenticated() { if (string.IsNullOrEmpty(Url)) { _server = null; } else { Uri uri; if (!Uri.IsWellFormedUriString(Url, UriKind.Absolute)) { // maybe it is not an Uri but instance name var servers = RegisteredTfsConnections.GetConfigurationServers(); var registered = servers.FirstOrDefault(s => String.Compare(s.Name, Url, StringComparison.OrdinalIgnoreCase) == 0); if (registered == null) { throw new GitTfsException("Given tfs name is not correct URI and not found as a registered TFS instance"); } uri = registered.Uri; } else { uri = new Uri(Url); } _server = HasCredentials ? new TfsTeamProjectCollection(uri, GetCredential(), new UICredentialsProvider()) : new TfsTeamProjectCollection(uri, new UICredentialsProvider()); _server.EnsureAuthenticated(); } }
/// <inheritdoc/> protected override void DoProcessRecord() { if (Server.Equals("localhost", StringComparison.OrdinalIgnoreCase) || Server.Equals(".")) { Server = Environment.MachineName; } WriteObject(RegisteredTfsConnections.GetConfigurationServers().Where(s => s.Name.IsLike(Server)), true); }