public static AvailableInfo GetCurrent(string ideName, Solution solution, SettingsSet cfg, GlobalSettingsPageGrid globalSettings) { var info = new AvailableInfo { IdeName = ideName, Solution = solution, GlobalSettings = globalSettings, Cfg = cfg, ElevationSuffix = CustomizeVSWindowTitle.CurrentPackage.ElevationSuffix }; try { info.ActiveDocument = Globals.DTE.ActiveDocument; } catch { // Do nothing } try { info.ActiveWindow = Globals.DTE.ActiveWindow; } catch { // Do nothing } var solutionFp = info.Solution?.FullName; if (info.ActiveDocument == null && string.IsNullOrEmpty(solutionFp)) { if (info.ActiveWindow == null || info.ActiveWindow.Caption == Globals.DTE.MainWindow.Caption) { return(null); } } info.DocumentName = DocumentHelper.GetActiveDocumentNameOrEmpty(info.ActiveDocument); info.DocumentPath = DocumentHelper.GetActiveDocumentPathOrEmpty(info.ActiveDocument); info.WindowName = DocumentHelper.GetActiveWindowNameOrEmpty(info.ActiveWindow); if (!string.IsNullOrEmpty(solutionFp)) { info.Path = solutionFp; } else { info.Path = info.DocumentPath; } info.PathParts = SplitPath(info.Path); if (!string.IsNullOrEmpty(info.Path)) { info.PathParts[0] = System.IO.Path.GetPathRoot(info.Path).Replace("\\", ""); } info.DocumentPathParts = SplitPath(info.DocumentPath); if (!string.IsNullOrEmpty(info.DocumentPath)) { info.DocumentPathParts[0] = System.IO.Path.GetPathRoot(info.DocumentPath).Replace("\\", ""); } return(info); }
internal string GetNewTitle(Solution solution, string pattern, SettingsSet cfg) { var info = AvailableInfo.GetCurrent(ideName: this.IDEName, solution: solution, cfg: cfg, globalSettings: this.UiSettings); if (info == null) { return(this.IDEName); } pattern = TagRegex.Replace(pattern, match => { try { var tag = match.Groups[1].Value; try { if (this.SimpleTagResolvers.TryGetValue(tag, out var resolver)) { return(resolver.Resolve(info: info)); } foreach (var tagResolver in this.TagResolvers) { if (tagResolver.TryResolve(tag: tag, info: info, s: out var value)) { return(value); } }