/// <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>
        protected virtual EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path)
        {
            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);
        }
Пример #2
0
        /// <include file='doc\Automation.uex' path='docs/doc[@for="OAProjectItem.get_FileNames"]/*' />
        public virtual string get_FileNames(short index)
        {
            if (index < 1)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            HierarchyNode node = null;

            if (this.node is FileNode)
            {
                node = this.node;
            }
            else
            {
                int           i    = index - 1; // index is 1-based
                OAProjectItem item = (OAProjectItem)this.items.items[i];
                node = item.node;
            }
            if (node is FileNode)
            {
                FileNode file = (FileNode)node;
                return(file.FileName);
            }
            return(null);
        }
Пример #3
0
        EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op)
        {
            ProjectNode proj = this.project.project;

            VSADDRESULT[] result = new VSADDRESULT[1];
            NativeMethods.ThrowOnFailure(proj.AddItem(node.ID, op, path, 0, new string[1] {
                path
            }, IntPtr.Zero, null));
            if (result[0] == VSADDRESULT.ADDRESULT_Success)
            {
                HierarchyNode      child = node.LastChild;
                EnvDTE.ProjectItem item  = new OAProjectItem(this.project, child);
                this.items.Add(item);
                return(item);
            }
            return(null);
        }
Пример #4
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>
        protected virtual EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path)
        {
            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;
        }
Пример #5
0
 EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op)
 {
     ProjectNode proj = this.project.project;
     VSADDRESULT[] result = new VSADDRESULT[1];
     NativeMethods.ThrowOnFailure(proj.AddItem(node.ID, op, path, 0, new string[1] { path }, IntPtr.Zero, null));
     if (result[0] == VSADDRESULT.ADDRESULT_Success)
     {
         HierarchyNode child = node.LastChild;
         EnvDTE.ProjectItem item = new OAProjectItem(this.project, child);
         this.items.Add(item);
         return item;
     }
     return null;
 }