如何使用控件和窗体的Visual Studio访问TFS版本控制 [英] How to use the Controls and Forms of Visual Studio to access the TFS Version Control

查看:200
本文介绍了如何使用控件和窗体的Visual Studio访问TFS版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从命名空间中的类 Microsoft.TeamFoundation.Client Microsoft.TeamFoundation.VersionControl.Client 就可以访问Team Foundation Server的版本控制(TFS- VC)编程。

With the Classes from the namespaces Microsoft.TeamFoundation.Client and Microsoft.TeamFoundation.VersionControl.Client it is possible to access the Team Foundation Server Version Control (TFS-VC) programatically.

时,也可​​以使用中所使用的Visual Studio中在自己的应用程序的控制和形式?它看起来像极了类中的 Microsoft.TeamFoundation.VersionControl.Controls 标记为内部的,因此不能用外...

Is it also possible to use the Controls and Forms that are used in Visual Studio in an own application? It looks like most of the classes in Microsoft.TeamFoundation.VersionControl.Controls are marked as internal and therefore not available outside...

推荐答案

这是可能的,下面我用TFS2010,发现它somehwere在互联网上,它打开了SourceControlFileSelector:

It is possible, the following I used for TFS2010 and found it somehwere in the internet, it opens the SourceControlFileSelector:

                VersionControlServer versionControlServer = (VersionControlServer)tfsConnection.GetService(typeof(VersionControlServer));
                Assembly controlsAssembly = Assembly.GetAssembly(typeof(Microsoft.TeamFoundation.VersionControl.Controls.ControlAddItemsExclude));

                Type vcChooseItemDialogType = controlsAssembly.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogChooseItem");
                ConstructorInfo ci = vcChooseItemDialogType.GetConstructor(
                                   BindingFlags.Instance | BindingFlags.NonPublic,
                                   null,
                                   new Type[] { typeof(VersionControlServer) },
                                   null);
                _chooseItemDialog = (Form)ci.Invoke(new object[] { versionControlServer });
                _chooseItemDialog.ShowDialog();
                this.DialogResult = _chooseItemDialog.DialogResult;


                _selectItemProperty = vcChooseItemDialogType.GetProperty("SelectedItem", BindingFlags.Instance | BindingFlags.NonPublic);
                Item selectedItem = (Item)_selectItemProperty.GetValue(_chooseItemDialog, null);

有关TFS2012有一些对话框直接使用,如TeamProjectPicker:

For TFS2012 there are some dialogs directly usable, like the TeamProjectPicker:

        TeamProjectPicker dp = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false);
        DialogResult dr = dp.ShowDialog();
        if (dr.Equals(DialogResult.OK) && dp.SelectedTeamProjectCollection != null)
        {
            Name = dp.SelectedTeamProjectCollection.ConfigurationServer.Name;
            configTfsUrl = dp.SelectedTeamProjectCollection.ConfigurationServer.Uri.AbsoluteUri;
            tfsUrl = dp.SelectedTeamProjectCollection.Uri;
        }

这篇关于如何使用控件和窗体的Visual Studio访问TFS版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆