public bool UpdateDocumentHierarchy(IEnumerable<string> pathsToUpdate, FilesPatternProvider filesPatternProvider, BackgroundIndexer worker)
        {
            if (DocumentHierarchy == null)
            {
                return false;
            }
            var documentHierarchyIndexer = new DocumentHierarchyIndexer(DocumentHierarchy);
            bool changed = false;
            foreach (string path in pathsToUpdate)
            {
                INode node = DocumentHierarchy.GetNode(path);
                bool nodeShouldBeRemoved = node != null;
                var fileSystemEntryList = GetFileList(path, filesPatternProvider, worker);

                foreach (PowershellFileParser fileSystemEntry in fileSystemEntryList)
                {
                    // this is to prevent from reporting progress after deletion if the node is only updated
                    if (fileSystemEntry.Path == path && node != null)
                    {
                        DocumentHierarchy.RemoveNode(node);
                        nodeShouldBeRemoved = false;
                    }
                    documentHierarchyIndexer.AddFileSystemNode(fileSystemEntry);
                    changed = true;
                }
                if (nodeShouldBeRemoved)
                {
                    DocumentHierarchy.RemoveNode(node);
                    changed = true;
                    ReportProgress(worker, path);
                }
            }
            return changed;
        }
        public bool UpdateDocumentHierarchy(IEnumerable <string> pathsToUpdate, FilesPatternProvider filesPatternProvider, BackgroundIndexer worker)
        {
            if (this.DocumentHierarchy == null)
            {
                return(false);
            }
            var  documentHierarchyIndexer = new DocumentHierarchyIndexer(this.DocumentHierarchy);
            bool changed = false;

            foreach (string path in pathsToUpdate)
            {
                INode node = this.DocumentHierarchy.GetNode(path);
                bool  nodeShouldBeRemoved = node != null;
                var   fileSystemEntryList = this.GetFileList(path, filesPatternProvider, worker);

                foreach (PowershellFileParser fileSystemEntry in fileSystemEntryList)
                {
                    // this is to prevent from reporting progress after deletion if the node is only updated
                    if (fileSystemEntry.Path == path && node != null)
                    {
                        this.DocumentHierarchy.RemoveNode(node);
                        nodeShouldBeRemoved = false;
                    }
                    documentHierarchyIndexer.AddFileSystemNode(fileSystemEntry);
                    changed = true;
                }
                if (nodeShouldBeRemoved)
                {
                    this.DocumentHierarchy.RemoveNode(node);
                    changed = true;
                    this.ReportProgress(worker, path);
                }
            }
            return(changed);
        }
Exemple #3
0
 public DocumentHierarchyFactory(PowershellFileParser powershellFileParser, DocumentHierarchyIndexer documentHierarchyIndexer)
 {
     this.powershellFileParser     = powershellFileParser;
     this.documentHierarchyIndexer = documentHierarchyIndexer;
 }