public bool Update(SettingsSet settings)
 {
     if (this.IsReloadingNeeded)
     {
         this.TryReloadSettings();
     }
     foreach (var settingsSet in this.SettingsSets)
     {
         bool bMatched;
         if (!this.IsGlobalConfig)
         {
             // ignore paths
             bMatched = true;
         }
         else
         {
             bMatched = false;
             foreach (var path in settingsSet.Paths)
             {
                 bMatched = (-1 == path.IndexOfAny(PathSeparators) ?
                             path.Equals(settings.SolutionFileName, StringComparison.CurrentCultureIgnoreCase) :
                             path.Equals(settings.SolutionFilePath, StringComparison.CurrentCultureIgnoreCase)) ||
                            (path.Contains("*") || path.Contains("?")) && new Wildcard(path, RegexOptions.IgnoreCase).IsMatch(settings.SolutionFilePath);
                 if (bMatched)
                 {
                     break;
                 }
             }
         }
         if (bMatched)
         {
             try {
                 settings.Merge(settingsSet);
                 return(true);
             }
             catch (Exception ex) {
                 try {
                     if (CustomizeVSWindowTitle.CurrentPackage.UiSettings.EnableDebugMode)
                     {
                         CustomizeVSWindowTitle.WriteOutput("settings.Merge(settingsSet) exception: " + ex);
                     }
                 }
                 catch {
                     // ignored
                 }
                 return(false);
             }
         }
     }
     return(false);
 }
Пример #2
0
        ///'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        // Overriden Package Implementation

        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            CurrentPackage = this;

            this.GlobalSettingsWatcher.SettingsCleared   = this.OnSettingsCleared;
            this.SolutionSettingsWatcher.SettingsCleared = this.OnSettingsCleared;

            //Every 5 seconds, we check the window titles in case we missed an event.
            this.ResetTitleTimer = new System.Windows.Forms.Timer {
                Interval = 5000
            };
            this.ResetTitleTimer.Tick += this.UpdateWindowTitleAsync;
            this.ResetTitleTimer.Start();
        }
        //Private VersionSpecificAssembly As Assembly

        /// <summary>
        /// Default constructor of the package.
        /// Inside this method you can place any initialization code that does not require
        /// any Visual Studio service because at this point the package object is created but
        /// not sited yet inside Visual Studio environment. The place to do all the other
        /// initialization is the Initialize method.
        /// </summary>
        public CustomizeVSWindowTitle()
        {
            CurrentPackage = this;
            Globals.DTE    = (DTE2)GetGlobalService(typeof(DTE));
            Globals.DTE.Events.DebuggerEvents.OnEnterBreakMode  += this.OnIdeEvent;
            Globals.DTE.Events.DebuggerEvents.OnEnterRunMode    += this.OnIdeEvent;
            Globals.DTE.Events.DebuggerEvents.OnEnterDesignMode += this.OnIdeEvent;
            Globals.DTE.Events.DebuggerEvents.OnContextChanged  += this.OnIdeEvent;
            Globals.DTE.Events.SolutionEvents.AfterClosing      += this.OnIdeSolutionEvent;
            Globals.DTE.Events.SolutionEvents.Opened            += this.OnIdeSolutionEvent;
            Globals.DTE.Events.SolutionEvents.Renamed           += this.OnIdeSolutionEvent;
            Globals.DTE.Events.WindowEvents.WindowCreated       += this.OnIdeEvent;
            Globals.DTE.Events.WindowEvents.WindowClosing       += this.OnIdeEvent;
            Globals.DTE.Events.WindowEvents.WindowActivated     += this.OnIdeEvent;
            Globals.DTE.Events.DocumentEvents.DocumentOpened    += this.OnIdeEvent;
            Globals.DTE.Events.DocumentEvents.DocumentClosing   += this.OnIdeEvent;
            this.TagResolvers = new List <ITagResolver> {
                new DocumentNameResolver(),
                new ProjectNameResolver(),
                new StartupProjectNamesResolver(),
                new DocumentProjectNameResolver(),
                new DocumentProjectFileNameResolver(),
                new SolutionNameResolver(),
                new DocumentPathResolver(),
                new DocumentParentPathResolver(),
                new PathResolver(),
                new ParentPathResolver(),
                new ParentResolver(),
                new IdeNameResolver(),
                new ElevationSuffixResolver(),
                new VsMajorVersionResolver(),
                new VsMajorVersionYearResolver(),
                new PlatformNameResolver(),
                new ConfigurationNameResolver(),
                new GitBranchNameResolver(),
                new HgBranchNameResolver(),
                new SvnResolver(),
                new WorkspaceNameResolver(),
                new WorkspaceOwnerNameResolver(),
                new VsProcessIdResolver(),
                new EnvResolver(),
                new DebuggedProcessesArgsResolver()
            };
            this.SupportedTags      = this.TagResolvers.SelectMany(r => r.TagNames).ToArray();
            this.SimpleTagResolvers = this.TagResolvers.OfType <ISimpleTagResolver>().ToDictionary(t => t.TagName, t => t);
        }