private void SelectLocalPath(string localPath, TraceLogger logger, string name) { logger.Log($"The local path is '{localPath}'."); var tfs = new TfsWrapper(); logger.Log($"The tfs is '{tfs}'."); var versionControlServer = tfs.GetVersionControlServer(); if (versionControlServer != null) { logger.Log($"The versionControlServer is '{versionControlServer}'."); var workspace = versionControlServer.GetWorkspace(localPath); logger.Log($"The workspace is '{workspace.Name}'."); var serverPath = workspace.TryGetServerItemForLocalItem(localPath); logger.Log($"The serverPath is '{serverPath}'."); var sourceControlExplorer = tfs.GetSourceControlExplorer(); tfs.SelectInSourceControlExplorer(serverPath, workspace, sourceControlExplorer); } else { logger.Log($"The file {localPath} is not under source control."); } logger.Log($"End of selecting '{name}'."); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var logger = new TraceLogger(dte); var selectedItem = GetFirstSelectedItem(dte2?.ToolWindows.SolutionExplorer); if (selectedItem != null) { logger.Log($"The selected item is '{selectedItem.Name}'."); var localPath = GetLocalePath(selectedItem); if (!string.IsNullOrEmpty(localPath)) { logger.Log($"The locale path is '{localPath}'."); var tfs = new TfsWrapper(); logger.Log($"The tfs is '{tfs}'."); var versionControlServer = tfs.GetVersionControlServer(); if (versionControlServer != null) { logger.Log($"The versionControlServer is '{versionControlServer}'."); var workspace = versionControlServer.GetWorkspace(localPath); logger.Log($"The workspace is '{workspace.Name}'."); var serverPath = workspace.TryGetServerItemForLocalItem(localPath); logger.Log($"The serverPath is '{serverPath}'."); var sourceControlExplorer = tfs.GetSourceControlExplorer(); tfs.SelectInSourceControlExplorer(serverPath, workspace, sourceControlExplorer); } else { logger.Log($"The file {localPath} is not under source control."); } logger.Log($"End of selecting '{selectedItem.Name}'."); } else { logger.Log($"There is no local path for the selected item '{selectedItem.Name}'."); } } else { logger.Log($"No file selected."); } }