本文整理汇总了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;
}