private void SetupFileSystemWatcherEvents(IScheduler scheduler)
 {
    var changed = Observable
       .FromEventPattern<ChangedEventArgs>(h => _fileSystemWatcher.Changed += h, h => _fileSystemWatcher.Changed -= h)
       .Select(x => new Action<SolutionChangedEventArgs>(y => FileSystemItemChanged(x.EventArgs, y)));
    var created = Observable
       .FromEventPattern<CreatedEventArgs>(h => _fileSystemWatcher.Created += h, h => _fileSystemWatcher.Created -= h)
       .Select(x => new Action<SolutionChangedEventArgs>(y => FileSystemItemCreated(x.EventArgs, y)));
    var renamed = Observable
       .FromEventPattern<RenamedEventArgs>(h => _fileSystemWatcher.Renamed += h, h => _fileSystemWatcher.Renamed -= h)
       .Select(x => new Action<SolutionChangedEventArgs>(y => FileSystemItemRenamed(x.EventArgs, y)));
    Observable.Merge(changed, created, renamed)
              .Buffer(1.Seconds(), scheduler)
              .Subscribe(source =>
                         {
                            if (!source.Any()) return;
                            var args = new SolutionChangedEventArgs();
                            source.Each(x => x(args));
                            if (args.IsEmpty) return;
                            Changed(this, args);
                         });
 }
      private void FileSystemItemChanged(ChangedEventArgs args, SolutionChangedEventArgs solutionArgs)
      {
         if (_solutionPath.Equals(args.Path, StringComparison.CurrentCultureIgnoreCase))
         {
            var keys = _projects.Keys;
            ReloadSolution();
            keys.Where(x => !_projects.ContainsKey(x)).Each(x => solutionArgs.DeletedProjects.Add(x));
            _projects.Keys.Where(x => !keys.Contains(x)).Each(x => solutionArgs.AddedProjects.Add(x));
            return;
         }

         if (_projects.ContainsKey(args.Path))
         {
            _projects[args.Path] = LoadProject(args.Path);
            solutionArgs.ChangedProjects.Add(args.Path);
            return;
         }

         foreach (var projectPath in _projects.Where(x => x.Value.Files.Contains(args.Path)).Select(x => x.Key))
         {
            solutionArgs.ChangedProjects.Add(projectPath);
            return;
         }

         foreach (var projectPath in _projects.Where(x => x.Value.References.Contains(args.Path)).Select(x => x.Key))
         {
            solutionArgs.ChangedProjects.Add(projectPath);
            return;
         }
      }
      private void FileSystemItemRenamed(RenamedEventArgs args, SolutionChangedEventArgs solutionArgs)
      {
         if (_projects.ContainsKey(args.NewPath))
         {
            _projects[args.NewPath] = LoadProject(args.NewPath);
            solutionArgs.ChangedProjects.Add(args.NewPath);
            return;
         }

         foreach (var projectPath in _projects.Where(x => x.Value.Files.Contains(args.NewPath)).Select(x => x.Key))
         {
            solutionArgs.ChangedProjects.Add(projectPath);
            return;
         }

         foreach (var projectPath in _projects.Where(x => x.Value.References.Contains(args.NewPath)).Select(x => x.Key))
         {
            solutionArgs.ChangedProjects.Add(projectPath);
            return;
         }
      }