protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (watcher != null)
         {
             watcher.Dispose();
             watcher = null;
         }
     }
 }
        /// <summary>
        /// Sets up filesystem watches to watch directories for each solution for changes.
        /// </summary>
        private void SetupWatchers()
        {
            if (watcher != null)
            {
                watcher.Dispose();
            }

            watcher              = new MultiFileSystemWatcher();
            watcher.FileChanged += TestContainerUpdated;

            // Subscribe to the solution directory, which should pick up most changes
            string solutionDirectory, solutionFile, userOptionsFile;

            if (solutionService.GetSolutionInfo(out solutionDirectory, out solutionFile, out userOptionsFile) == VSConstants.S_OK)
            {
                // Ensure the solution dir ends with \ so we can compare when looking for subfolders
                if (!solutionDirectory.EndsWith("\\"))
                {
                    solutionDirectory = solutionDirectory + "\\";
                }

                foreach (var filePattern in this.WatchedFilePatterns)
                {
                    watcher.AddWatcher(solutionDirectory, filePattern);
                }

                // Get all directories that had test containers that are not already children of the solution dir (it's already being watched)
                var dirs = cachedTestContainers
                           .Select(tc => Path.GetDirectoryName(tc.Source) + "\\")
                           .Distinct(StringComparer.OrdinalIgnoreCase)
                           .Where(tc => !tc.StartsWith(solutionDirectory, StringComparison.OrdinalIgnoreCase));

                foreach (var dir in dirs)
                {
                    foreach (var filePattern in this.WatchedFilePatterns)
                    {
                        watcher.AddWatcher(dir, filePattern);
                    }
                }
            }

            // Also subscribe to the projects own changes to deal with new items being added outside of the solution directory
            uint pdwCookie;

            foreach (var p in solutionService.GetProjects())
            {
                p.AdviseHierarchyEvents(this, out pdwCookie);
            }
        }
        /// <summary>
        /// Sets up filesystem watches to watch directories for each solution for changes.
        /// </summary>
        private void SetupWatchers()
        {
            if (watcher != null)
                watcher.Dispose();

            watcher = new MultiFileSystemWatcher();
            watcher.FileChanged += TestContainerUpdated;

            // Subscribe to the solution directory, which should pick up most changes
            string solutionDirectory, solutionFile, userOptionsFile;
            if (solutionService.GetSolutionInfo(out solutionDirectory, out solutionFile, out userOptionsFile) == VSConstants.S_OK)
            {
                // Ensure the solution dir ends with \ so we can compare when looking for subfolders
                if (!solutionDirectory.EndsWith("\\"))
                    solutionDirectory = solutionDirectory + "\\";

                foreach (var filePattern in this.WatchedFilePatterns)
                    watcher.AddWatcher(solutionDirectory, filePattern);

                // Get all directories that had test containers that are not already children of the solution dir (it's already being watched)
                var dirs = cachedTestContainers
                    .Select(tc => Path.GetDirectoryName(tc.Source) + "\\")
                    .Distinct(StringComparer.OrdinalIgnoreCase)
                    .Where(tc => !tc.StartsWith(solutionDirectory, StringComparison.OrdinalIgnoreCase));

                foreach (var dir in dirs)
                {
                    foreach (var filePattern in this.WatchedFilePatterns)
                        watcher.AddWatcher(dir, filePattern);
                }
            }

            // Also subscribe to the projects own changes to deal with new items being added outside of the solution directory
            uint pdwCookie;
            foreach (var p in solutionService.GetProjects())
                p.AdviseHierarchyEvents(this, out pdwCookie);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (watcher != null)
         {
             watcher.Dispose();
             watcher = null;
         }
     }
 }