Beispiel #1
0
        /// <summary>
        /// Evaluates the result of an add operation.
        /// </summary>
        /// <param name="result">The VSADDRESULT returned by the Add methods</param>
        /// <param name="path">The full path of the item added.</param>
        /// <returns>A ProjectItem object.</returns>
        public 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
                        {
                            item = new OAProjectItem <HierarchyNode>(this.Project, nodeAdded);
                        }

                        this.Items.Add(item);
                        return item;
                    }
                }
                return null;
            }));
        }
        /// <summary>
        /// Evaluates the result of an add operation.
        /// </summary>
        /// <param name="result">The VSADDRESULT returned by the Add methods</param>
        /// <param name="path">The full path of the item added.</param>
        /// <returns>A ProjectItem object.</returns>
        public /*protected, but public for FSharp.Project.dll*/ 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);
                        }
#if UNUSED_NESTED_PROJECTS
                        else if (nodeAdded is NestedProjectNode)
                        {
                            item = new OANestedProjectItem(this.Project, nodeAdded as NestedProjectNode);
                        }
#endif
                        else
                        {
                            item = new OAProjectItem <HierarchyNode>(this.Project, nodeAdded);
                        }

                        this.Items.Add(item);
                        return item;
                    }
                }
                return null;
            }));
        }