喬諾的答案是非常有幫助和專注。我繼續創建了一個使用反射調用對話框的代碼片段(適用於TFS 2010 SP1中的我)。希望這對其他有相同問題的人有用。如前所述,這種方法不能保證在未來的版本中沒有變化。
public class TfsHistoryDialogWrapper
{
private readonly Type _dialogHistoryType;
private readonly object _historyDialogInstance;
public TfsHistoryDialogWrapper(VersionControlServer versionControl, string historyItem, VersionSpec itemVersion, int itemDeletionId, RecursionType recursionType, VersionSpec versionFrom, VersionSpec versionTo, string userFilter, int maxVersions, bool? slotMode)
{
Assembly tfsAssembly = typeof(Microsoft.TeamFoundation.VersionControl.Controls.LocalPathLinkBox).Assembly;
_dialogHistoryType = tfsAssembly.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogHistory");
_historyDialogInstance = _dialogHistoryType.GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance,
null,
new Type[]{typeof(VersionControlServer), typeof(string), typeof(VersionSpec), typeof(int), typeof(RecursionType), typeof(VersionSpec), typeof(VersionSpec), typeof(string), typeof(int), typeof(bool?)},
null).Invoke(new object[]{ versionControl, historyItem, itemVersion, itemDeletionId, recursionType, versionFrom, versionTo, userFilter, maxVersions, slotMode });
}
public void ShowDialog()
{
_dialogHistoryType.GetMethod("ShowDialog", new Type[]{}).Invoke(_historyDialogInstance, new object[]{});
}
}