Esempio n. 1
0
		async void CheckWorkspaceItems (object sender, FileEventArgs args)
		{
			HashSet<FilePath> files = new HashSet<FilePath> (args.Select (e => e.FileName.CanonicalPath));
			foreach (Solution s in GetAllSolutions ().Where (sol => sol.GetItemFiles (false).Any (f => files.Contains (f.CanonicalPath))))
				await OnCheckWorkspaceItem (s);
			
			foreach (Project p in GetAllProjects ().Where (proj => proj.GetItemFiles (false).Any (f => files.Contains (f.CanonicalPath))))
				await OnCheckProject (p);
		}
        void OnSystemFileDeleted(object sender, FileEventArgs args)
        {
            if (Context.Tree.IsDestroyed)
            {
                return;
            }
            foreach (FileEventInfo e in args)
            {
                try {
                    Project project = GetProjectForFile(e.FileName);

                    ITreeBuilder tb = Context.GetTreeBuilder();

                    if (e.IsDirectory)
                    {
                        if (tb.MoveToObject(new ProjectFolder(e.FileName, project)))
                        {
                            if (tb.Options ["ShowAllFiles"] && (project == null || !ProjectFolderCommandHandler.PathExistsInProject(project, e.FileName)))
                            {
                                tb.Remove();
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (tb.MoveToObject(new SystemFile(e.FileName, project)))
                        {
                            tb.Remove();
                            return;
                        }
                    }

                    // Find the parent folder, and update it's children count

                    string parentPath = Path.GetDirectoryName(e.FileName);
                    if (tb.MoveToObject(new ProjectFolder(parentPath, project)))
                    {
                        if (tb.Options ["ShowAllFiles"] && Directory.Exists(parentPath))
                        {
                            tb.UpdateChildren();
                        }
                    }
                } catch (Exception ex) {
                    LoggingService.LogInternalError($"Error while updating project tree in OnSystemFileDeleted : {string.Join (", ", args.Select (x => x.FileName))}.", ex);
                }
            }
        }