当前位置: 首页>>代码示例>>C#>>正文


C# HierarchyNode.IncludeInProjectWithRefresh方法代码示例

本文整理汇总了C#中HierarchyNode.IncludeInProjectWithRefresh方法的典型用法代码示例。如果您正苦于以下问题:C# HierarchyNode.IncludeInProjectWithRefresh方法的具体用法?C# HierarchyNode.IncludeInProjectWithRefresh怎么用?C# HierarchyNode.IncludeInProjectWithRefresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HierarchyNode的用法示例。


在下文中一共展示了HierarchyNode.IncludeInProjectWithRefresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenameFileNode

        /// <summary>
        /// Renames the file in the hierarchy by removing old node and adding a new node in the hierarchy.
        /// </summary>
        /// <param name="oldFileName">The old file name.</param>
        /// <param name="newFileName">The new file name</param>
        /// <param name="newParentId">The new parent id of the item.</param>
        /// <returns>The newly added FileNode.</returns>
        /// <remarks>While a new node will be used to represent the item, the underlying MSBuild item will be the same and as a result file properties saved in the project file will not be lost.</remarks>
        internal FileNode RenameFileNode(string oldFileName, string newFileName, HierarchyNode newParent) {
            if (CommonUtils.IsSamePath(oldFileName, newFileName)) {
                // We do not want to rename the same file
                return null;
            }

            //If we are included in the project and our parent isn't then
            //we need to bring our parent into the project
            if (!this.IsNonMemberItem && newParent.IsNonMemberItem) {
                ErrorHandler.ThrowOnFailure(newParent.IncludeInProjectWithRefresh(false));
            }

            // Retrieve child nodes to add later.
            List<HierarchyNode> childNodes = this.GetChildNodes();

            FileNode renamedNode;
            using (this.ProjectMgr.ExtensibilityEventsDispatcher.Suspend()) {

                // Remove this from its parent.
                ProjectMgr.OnItemDeleted(this);
                this.Parent.RemoveChild(this);

                // Update name in MSBuild
                this.ItemNode.Rename(CommonUtils.GetRelativeFilePath(ProjectMgr.ProjectHome, newFileName));

                // Request a new file node be made.  This is used to replace the old file node.  This way custom
                // derived FileNode types will be used and correctly associated on rename.  This is useful for things 
                // like .txt -> .js where the file would now be able to be a startup project/file.
                renamedNode = this.ProjectMgr.CreateFileNode(this.ItemNode);

                renamedNode.ItemNode.RefreshProperties();
                renamedNode.UpdateCaption();
                newParent.AddChild(renamedNode);
                renamedNode.Parent = newParent;
            }

            UpdateCaption();
            ProjectMgr.ReDrawNode(renamedNode, UIHierarchyElement.Caption);

            renamedNode.ProjectMgr.ExtensibilityEventsDispatcher.FireItemRenamed(this, oldFileName);

            //Update the new document in the RDT.
            DocumentManager.RenameDocument(renamedNode.ProjectMgr.Site, oldFileName, newFileName, renamedNode.ID);

            //Select the new node in the hierarchy
            renamedNode.ExpandItem(EXPANDFLAGS.EXPF_SelectItem);

            // Add children to new node and rename them appropriately.
            childNodes.ForEach(x => renamedNode.AddChild(x));
            RenameChildNodes(renamedNode);

            return renamedNode;
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:61,代码来源:FileNode.cs


注:本文中的HierarchyNode.IncludeInProjectWithRefresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。