在 Visual Studio 外部使用 VersionControlExt.Explorer
我正在开发一个 TFS 工具来协助我们公司的开发人员。
该工具需要能够像在源代码管理资源管理器中一样“浏览”TFS 服务器。我相信通过使用 VersionControlExt.Explorer.SelectedItems,将会弹出一个 UI,使用户能够浏览 TFS 服务器(如果我错了,请纠正我)。
但是,VersionControlExt 仅在 Visual Studio(又名插件)内开发时才可访问。不幸的是,我正在开发一个不能在 VS 内运行的 Windows 应用程序。
所以问题是,我可以在 Visual Studio 之外使用 VersionControlExt 吗?如果是,怎么办?
这里尝试在 Visual Studio 之外使用“更改集详细信息”对话框
string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Assembly vcControls = Assembly.LoadFile(path + @"\Microsoft.TeamFoundation.VersionControl.Controls.dll");
Assembly vcClient = Assembly.LoadFile(path + @"\Microsoft.TeamFoundation.VersionControl.Client.dll");
Type dialogChangesetDetailsType = vcControls.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogChangesetDetails",true);
Type[] ctorTypes = new Type[3] {vcClient.GetType("Microsoft.TeamFoundation.VersionControl.Client.VersionControlSever"),
vcClient.GetType("Microsoft.TeamFoundation.VersionControl.Client.Changeset"), typeof(System.Boolean)};
ConstructorInfo ctorInfo = dialogChangesetDetailsType.GetConstructor(ctorTypes);
Object[] ctorObjects = new Object[3] {VersionControlHelper.CurrentVersionControlServer, uc.ChangeSet, true};
Object oDialog = ctorInfo.Invoke(ctorObjects);
dialogChangesetDetailsType.InvokeMember("ShowDialog", BindingFlags.InvokeMethod, null, oDialog, null);
I'm developing a TFS tool to assist the developers in our company.
This said tool needs to be able to "browse" the TFS server like in the Source Control Explorer. I believe that by using VersionControlExt.Explorer.SelectedItems, a UI will pop-up that will enable the user to browse the TFS server (please correct me if I'm wrong).
However, VersionControlExt is only accessible when developing inside Visual Studio (aka Plugin). Unfortunately, I am developing a Windows Application that won;t run inside VS.
So the question is, Can I use VersionControlExt outside of Visual Studio? If yes, how?
Here's an attempt on using the Changset Details Dialog outside of Visual Studio
string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Assembly vcControls = Assembly.LoadFile(path + @"\Microsoft.TeamFoundation.VersionControl.Controls.dll");
Assembly vcClient = Assembly.LoadFile(path + @"\Microsoft.TeamFoundation.VersionControl.Client.dll");
Type dialogChangesetDetailsType = vcControls.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogChangesetDetails",true);
Type[] ctorTypes = new Type[3] {vcClient.GetType("Microsoft.TeamFoundation.VersionControl.Client.VersionControlSever"),
vcClient.GetType("Microsoft.TeamFoundation.VersionControl.Client.Changeset"), typeof(System.Boolean)};
ConstructorInfo ctorInfo = dialogChangesetDetailsType.GetConstructor(ctorTypes);
Object[] ctorObjects = new Object[3] {VersionControlHelper.CurrentVersionControlServer, uc.ChangeSet, true};
Object oDialog = ctorInfo.Invoke(ctorObjects);
dialogChangesetDetailsType.InvokeMember("ShowDialog", BindingFlags.InvokeMethod, null, oDialog, null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明我并不真正需要那个资源管理器。
我通过使用 TreeView 控件和 VersionControlServer.GetItems() 来完成此操作。
代码片段如下:
然后,每次用户展开节点时,我都会获取该节点下的所有项目。
Turns out that I don't really need that Explorer.
I accomplished this by using the TreeView control and VersionControlServer.GetItems().
Code snippet below:
Then, everytime the user expand the nodes, I get all the items under that node.