Esempio n. 1
0
        private EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path)
        {
            return(UIThread.Instance.RunSync <EnvDTE.ProjectItem>(() => {
                if (result == VSADDRESULT.ADDRESULT_Success)
                {
                    if (Directory.Exists(path) && !CommonUtils.HasEndSeparator(path))
                    {
                        path = path + Path.DirectorySeparatorChar;
                    }
                    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;
                        if (nodeAdded is FileNode)
                        {
                            item = new OAFileItem(this.Project, nodeAdded as FileNode);
                        }
                        else
                        {
                            item = new OAProjectItem(this.Project, nodeAdded);
                        }

                        return item;
                    }
                }
                return null;
            }));
        }
Esempio n. 2
0
        /// <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(this.Project.ProjectNode.Site.GetUIThread().Invoke <EnvDTE.ProjectItem>(() =>
            {
                if (result != VSADDRESULT.ADDRESULT_Failure)
                {
                    if (Directory.Exists(path))
                    {
                        path = CommonUtils.EnsureEndSeparator(path);
                    }
                    var 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;
                        if (nodeAdded is FileNode fileNode)
                        {
                            item = new OAFileItem(this.Project, fileNode);
                        }
                        else
                        {
                            item = new OAProjectItem(this.Project, nodeAdded);
                        }

                        return item;
                    }
                }
                return null;
            }));
        }
Esempio n. 3
0
        /// <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;
            });
        }
Esempio n. 4
0
        private EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path) {
            return UIThread.Instance.RunSync<EnvDTE.ProjectItem>(() => {
                if (result == VSADDRESULT.ADDRESULT_Success) {
                    if (Directory.Exists(path) && !CommonUtils.HasEndSeparator(path)) {
                        path = path + Path.DirectorySeparatorChar;
                    }
                    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;
                        if (nodeAdded is FileNode) {
                            item = new OAFileItem(this.Project, nodeAdded as FileNode);
                        } else {
                            item = new OAProjectItem(this.Project, nodeAdded);
                        }

                        return item;
                    }
                }
                return null;
            });
        }