/// <summary> /// Evaluates the result of an add operation. /// </summary> /// <param name="result">The <paramref name="VSADDRESULT"/> returned by the Add methods</param> /// <param name="path">The full path of the item added.</param> /// <returns>A ProjectItem object.</returns> private EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path) { return(Project.ProjectNode.Site.GetUIThread().Invoke <EnvDTE.ProjectItem>(() => { if (result != VSADDRESULT.ADDRESULT_Failure) { if (Directory.Exists(path)) { path = CommonUtils.EnsureEndSeparator(path); } HierarchyNode nodeAdded = this.NodeWithItems.ProjectMgr.FindNodeByFullPath(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; var fileNode = nodeAdded as FileNode; if (fileNode != null) { item = new OAFileItem(this.Project, fileNode); } else { item = new OAProjectItem(this.Project, nodeAdded); } return item; } } return null; })); }
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) { if (result == VSADDRESULT.ADDRESULT_Success) { HierarchyNode nodeAdded = 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(Project, nodeAdded as FileNode); } else { item = new OAProjectItem<HierarchyNode>(Project, nodeAdded); } Items.Add(item); return item; } } return null; }