2

とにかく、IBuildDefinitionまたは他の関連する「サービス」からコレクションURIを取得することはできますか。

ビルドテンプレートのコレクションにカスタムパラメーターとしてURIを指定する必要がないようにしています。UITypeEditorカスタムクラス内から(この場合は)プログラムで取得する方法を探しています。

ハードコーディングに頼らずにこれを照会する方法はありますか?ビルドプロセス自体(定義、コントローラー、エージェントなど)は、どのコレクションを処理しているかを知っているように見えますが、どうすればわかりますか?

更新:から継承している場合のサンプルコードは次のとおりですUITypeEditor。次に、 :のTeamProjectCollectionプロパティにアクセスするだけです。VersionControlService

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;
    }
4

2 に答える 2

1

TfsTeamProjectProjectionオブジェクトはIBuildServerから取得できます。

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

次に、このオブジェクトからUriを取得します。

于 2012-04-06T16:29:56.823 に答える
1

UITypeEditor.EditValueのオーバーライド内で、TeamProjectCollectionを取得するための関連するコード行は次のとおりです。

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

そしてそれはプロパティにあります

vcs.TeamProjectCollection
于 2012-04-13T19:08:43.280 に答える