是否可以从 IBuildDefinition
或其他相关“服务”获取集合 URI。
我试图避免必须将 URI 作为自定义参数提供给构建模板中的集合。我正在寻找一种方法(在本例中)从 UITypeEditor
自定义类中以编程方式检索它。
有没有一种方法可以在不诉诸硬编码的情况下查询此内容?在我看来,构建过程本身(定义、 Controller 、代理等)知道它们正在处理哪个集合,但我怎样才能找到?
更新:以下是从 UITypeEditor
继承时的示例代码。然后,您只需访问 VersionControlService
的 TeamProjectCollection
属性即可:
public class Editor : UITypeEditor
{
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (provider != null)
{
IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (service != null)
{
VersionControlServer vcs = provider.GetService(typeof(VersionControlServer)) as VersionControlServer;
// Do what you need to do with it here
}
}
return value;
}
public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
最佳答案
您可以从 IBuildServer 获取 TfsTeamProjectProjection 对象:
然后从这个对象中获取 Uri。
关于c# - TFS 自定义构建模板 - 获取不带 Uri 的团队项目集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10046216/