protected virtual EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path) { return(UIThread.DoOnUIThread(delegate() { if (result == VSADDRESULT.ADDRESULT_Success) { HierarchyNode nodeAdded = this.NodeWithItems.FindChild(path); Debug.Assert(nodeAdded != null, "We should have been able to find the new element in the hierarchy"); if (nodeAdded != null) { EnvDTE.ProjectItem item = null; if (nodeAdded is FileNode) { item = new OAFileItem(this.Project, nodeAdded as FileNode); } else if (nodeAdded is NestedProjectNode) { item = new OANestedProjectItem(this.Project, nodeAdded as NestedProjectNode); } else { item = new OAProjectItem <HierarchyNode>(this.Project, nodeAdded); } this.Items.Add(item); return item; } } return null; })); }
protected virtual ProjectItem EvaluateAddResult(VSADDRESULT result, string path) { return(ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (result == VSADDRESULT.ADDRESULT_Success) { HierarchyNode nodeAdded = this.NodeWithItems.FindChild(path); Debug.Assert(nodeAdded != null, "We should have been able to find the new element in the hierarchy"); if (nodeAdded != null) { ProjectItem item = null; if (nodeAdded is FileNode) { item = new OAFileItem(this.Project, nodeAdded as FileNode); } else if (nodeAdded is NestedProjectNode) { item = new OANestedProjectItem(this.Project, nodeAdded as NestedProjectNode); } else { item = new OAProjectItem <HierarchyNode>(this.Project, nodeAdded); } IEnumerable <ProjectItem> match = base.Items.Where((ProjectItem titem) => titem.Name == item.Name); if (match == null || match.Count() == 0) { base.Items.Add(item); } return item; } } return null; })); }