如果我想选择服务器及其项目,DomainProjectPicker的替代方案是什么?我知道一个名为TeamProjectPicker的新类,但这对我没有帮助。有人知道如何从这种类型的对话框中选择服务器吗?
谢谢,TS。
答案 0 :(得分:1)
据我所知,它与DomainProjectPicker大致相同。
以下是我如何使用它的代码示例:
if (tpp.ShowDialog() == DialogResult.OK)
{
try
{
//here you get the TfsTeamProjectCollection (the TeamFoundationServer class is also obsolete)
TfsTeamProjectCollection tfsProj = tpp.SelectedTeamProjectCollection;
//here you authenticate
tfsProj.Authenticate();
}
etc...
答案 1 :(得分:1)
您可以使用Microsoft.TeamFoundation.Client.dll中的 TeamProjectPicker 类。有一篇很棒的博客文章描述了如何纠缠对话:Using the TeamProjectPicker API in TFS 2010
以下是选择多个团队项目的代码示例:
Application.EnableVisualStyles(); // Makes it look nicer from a console app.
//"using" pattern is recommended as the picker needs to be disposed of
using (TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.MultiProject, false))
{
DialogResult result = tpp.ShowDialog();
if (result == DialogResult.OK)
{
System.Console.WriteLine("Selected Team Project Collection Uri: " + tpp.SelectedTeamProjectCollection.Uri);
System.Console.WriteLine("Selected Projects:");
foreach(ProjectInfo projectInfo in tpp.SelectedProjects)
{
System.Console.WriteLine(projectInfo.Name);
}
}
}
如果您不关心项目并且只希望用户能够选择服务器和集合,请在构造函数中使用TeamProjectPickerMode。 NoProject 。