TFS自定义构建模板 - 在没有Uri的情况下获取团队项目集合

问题描述 投票:2回答:2

无论如何从IBuildDefinition或其他相关的“服务”获取集合URI。

我试图避免必须在构建模板中将URI作为自定义参数提供给集合。我正在寻找一种方法,以编程方式从UITypeEditor自定义类中(在本例中)检索它。

有没有办法在不诉诸硬编码的情况下查询?在我看来,构建过程本身(定义,控制器,代理等)知道他们正在处理哪个集合但我怎么能找到?

更新:这是从UITypeEditor继承的示例代码。然后你只需访问TeamProjectCollectionVersionControlService属性:

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;
    }
c# tfs tfs2010
2个回答
1
投票

您可以从IBuildServer获取TfsTeamProjectProjection对象:

http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.client.ibuildserver.teamprojectcollection.aspx

然后从这个对象得到你的Uri。


1
投票

在UITypeEditor.EditValue的覆盖内部,获取TeamProjectCollection的相关代码行是

VersionControlServer vcs = provider.GetService(typeof(VersionControlServer)) as VersionControlServer;

然后是在财产

vcs.TeamProjectCollection
© www.soinside.com 2019 - 2024. All rights reserved.