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


C# HierarchyNode.AddChild方法代码示例

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


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

示例1: VerifySubFolderExists

        /// <include file='doc\Project.uex' path='docs/doc[@for="Project.VerifySubFolderExists"]/*' />
        /// <summary>
        /// takes a path and verifies that we have a node with that name, if not, add it to this node.
        /// </summary>
        public HierarchyNode VerifySubFolderExists(HierarchyNode parent, string strPath)
        {
            HierarchyNode folderNode = null;
            uint uiItemId;
            Url url = new Url(this.BaseURI, strPath);
            string strFullPath = url.AbsoluteUrl; 
            // folders end in our storage with a backslash, so add one...
            NativeMethods.ThrowOnFailure(this.ParseCanonicalName(strFullPath, out uiItemId));
            if (uiItemId == 0)
            {
                // folder does not exist yet...
                folderNode = CreateNode(this, HierarchyNodeType.Folder, strPath);
                parent.AddChild(folderNode);
            }
            else
            {
                folderNode = this.NodeFromItemId(uiItemId);
            }

            return folderNode;
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:25,代码来源:Project.cs

示例2: AddFileNodeToNode

 /// <summary>
 /// Add a file node to the hierarchy
 /// </summary>
 /// <param name="item">msbuild item to add</param>
 /// <param name="parentNode">Parent Node</param>
 /// <returns>Added node</returns>
 private HierarchyNode AddFileNodeToNode(Microsoft.Build.Evaluation.ProjectItem item, HierarchyNode parentNode)
 {
     FileNode node = this.CreateFileNode(new ProjectElement(this, item, false));
     parentNode.AddChild(node);
     return node;
 }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:12,代码来源:projectnode.cs

示例3: Reload

        /// <include file='doc\Project.uex' path='docs/doc[@for="Project.Reload"]/*' />
        public virtual void Reload()
        {
            if (this.myEngine == null || this.myEngine.BinPath == null)
            {
                this.myEngine = new MSBuild.Engine();
                // We must set the MSBuild path prior to calling CreateNewProject or we it will fail
                this.myEngine.BinPath = GetMsBuildPath();
            }
            this.projFile = myEngine.CreateNewProject();
            this.projFile.LoadFromFile(this.filename);
            MSBuild.PropertyGroup projectProperties = projFile.EvaluatedProperties;

            // load the guid
            if (projectProperties != null)
            {
                try
                {
                    this.projectGuid = new Guid(this.GetProjectProperty("ProjectGuid"));
                }
                catch
                {
                    this.projectGuid = Guid.NewGuid();
                }
            }

            // Process References
            MSBuild.ItemGroup references = this.projFile.GetEvaluatedItemsByType("Reference");
            referencesFolder = CreateNode(this, HierarchyNodeType.RefFolder, "References");
            AddChild(referencesFolder);
            foreach (MSBuild.Item reference in references)
            {
                HierarchyNode node = CreateNode(this, HierarchyNodeType.Reference, new ProjectElement(this, reference, false));

                referencesFolder.AddChild(node);
            }

            // Process Files
            MSBuild.ItemGroup projectFiles = this.projFile.EvaluatedItems;
            foreach (MSBuild.Item item in projectFiles)
            {
                // Ignore the item if it is a reference or folder
                if (String.Compare(item.Type, "Reference", true, CultureInfo.InvariantCulture) == 0
                    || String.Compare(item.Type, "Folder", true, CultureInfo.InvariantCulture) == 0
                    || String.Compare(item.Type, "ProjectReference", true, CultureInfo.InvariantCulture) == 0
                    || String.Compare(item.Type, "WebReference", true, CultureInfo.InvariantCulture) == 0
                    || String.Compare(item.Type, "WebReferenceFolder", true, CultureInfo.InvariantCulture) == 0)
                    continue;

                // MSBuilds tasks/targets can create items (such as object files),
                // such items are not part of the project per say, and should not be displayed.
                // so ignore those items.
                if (!this.IsItemTypeFileType(item.Type))
                    continue;


                string strPath = item.FinalItemSpec;
                HierarchyNode currentParent = this;

                strPath = Path.GetDirectoryName(strPath);
                if (strPath.Length > 0)
                {
                    // use the relative to verify the folders...
                    currentParent = CreateFolderNodes(strPath);
                }

                currentParent.AddChild(this.CreateNode(this, HierarchyNodeType.File, new ProjectElement(this, item, false)));
            }

            // Process Folders (useful to persist empty folder)
            MSBuild.ItemGroup folders = this.projFile.GetEvaluatedItemsByType("Folder");
            foreach (MSBuild.Item folder in folders)
            {
                string strPath = folder.FinalItemSpec;
                CreateFolderNodes(strPath);
            }

            SetProjectFileDirty(false);
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:79,代码来源:Project.cs

示例4: AddNewFileNodeToHierarchyCore

        private HierarchyNode AddNewFileNodeToHierarchyCore(HierarchyNode parentNode, string fileName, string linkPath)
        {
            HierarchyNode child;

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if (this.canFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                child = this.CreateDependentFileNode(fileName);
                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (!child.HasParentNodeNameRelation && String.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(fileName);
                child.ItemNode.SetMetadata(ProjectFileConstants.Link, linkPath);
                if (!String.IsNullOrEmpty(linkPath))
                {
                    child.ExcludeNodeFromScc = true;
                }
            }

            parentNode.AddChild(child);

            return child;
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:32,代码来源:projectnode.cs

示例5: AddDependentFileNodeToNode

        /// <summary>
        /// Add a dependent file node to the hierarchy
        /// </summary>
        /// <param name="item">msbuild item to add</param>
        /// <param name="parentNode">Parent Node</param>
        /// <returns>Added node</returns>
        private HierarchyNode AddDependentFileNodeToNode(Microsoft.Build.Evaluation.ProjectItem item, HierarchyNode parentNode)
        {
            FileNode node = this.CreateDependentFileNode(new ProjectElement(this, item, false));
            parentNode.AddChild(node);
            
            // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
            if (!node.HasParentNodeNameRelation && String.Compare(node.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
            {
                node.HasParentNodeNameRelation = true;
            }

            return node;
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:19,代码来源:projectnode.cs

示例6: AddNewFileNodeToHierarchy

        /// <summary>
        /// Adds a new file node to the hierarchy.
        /// </summary>
        /// <param name="parentNode">The parent of the new fileNode</param>
        /// <param name="fileName">The file name</param>
        protected virtual void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string fileName)
        {
            HierarchyNode child;

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if (this.canFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                child = this.CreateDependentFileNode(fileName);
                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(fileName);
            }

            parentNode.AddChild(child);

            // TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project?
            this.tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:33,代码来源:ProjectNode.cs

示例7: VerifySubFolderExists

        protected virtual FolderNode VerifySubFolderExists(string path, HierarchyNode parent)
        {
            FolderNode folderNode = null;
            uint uiItemId;
            Url url = new Url(this.BaseURI, path);
            string strFullPath = url.AbsoluteUrl;
            // Folders end in our storage with a backslash, so add one...
            this.ParseCanonicalName(strFullPath, out uiItemId);
            if ((uint)VSConstants.VSITEMID.Nil != uiItemId)
            {
                Debug.Assert(this.NodeFromItemId(uiItemId) is FolderNode, "Not a FolderNode");
                folderNode = (FolderNode)this.NodeFromItemId(uiItemId);
            }

            if (folderNode == null)
            {
                // folder does not exist yet...
                // We could be in the process of loading so see if msbuild knows about it
                ProjectElement item = null;
                foreach (Microsoft.Build.Evaluation.ProjectItem folder in MSBuildProject.GetItems(buildProject, ProjectFileConstants.Folder))
                {
                    if (String.Compare(folder.EvaluatedInclude.TrimEnd('\\'), path.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        item = new ProjectElement(this, folder, false);
                        break;
                    }
                }
                // If MSBuild did not know about it, create a new one
                if (item == null)
                    item = this.AddFolderToMsBuild(path);
                folderNode = this.CreateFolderNode(path, item);
                parent.AddChild(folderNode);
            }

            return folderNode;
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:36,代码来源:projectnode.cs

示例8: VerifySubFolderExists

    /// <include file='doc\Project.uex' path='docs/doc[@for="Project.VerifySubFolderExists"]/*' />
    /// <summary>
    /// takes a path and verifies that we have a node with that name, if not, add it to this node.
    /// </summary>
    public HierarchyNode VerifySubFolderExists(HierarchyNode parent, string strPath){
      HierarchyNode folderNode = null;
      uint uiItemId;
#if WHIDBEY
      Uri uri = new Uri(new Uri(this.projFile.BaseURI), strPath);
#else
      Uri uri = new Uri(new Uri(this.projFile.BaseURI), strPath, true);
#endif

      strPath = uri.LocalPath; //??? 
      // folders end in our storage with a backslash, so add one...
      strPath += "\\";
      this.ParseCanonicalName(strPath, out uiItemId);
      if (uiItemId == 0){
        // folder does not exist yet...
        folderNode = CreateNode(this, HierarchyNodeType.Folder, strPath);
        parent.AddChild(folderNode);
      } else{
        folderNode = this.NodeFromItemId(uiItemId);
      }

      return folderNode;
    }
开发者ID:dbremner,项目名称:specsharp,代码行数:27,代码来源:Project.cs

示例9: Reload

    /// <include file='doc\Project.uex' path='docs/doc[@for="Project.Reload"]/*' />
    public virtual void Reload(){
      this.projFile = new XmlDocument();
      this.projFile.Load(this.filename);
      this.xmlNode = this.projFile.DocumentElement;
      // load the guid
      XmlElement state = this.StateElement = (XmlElement)this.GetProjectStateElement(this.xmlNode);

      if (state != null){
        string projectGuid = state.GetAttribute("ProjectGuid");
        this.projectGuid = projectGuid == string.Empty ? new Guid() : new Guid(projectGuid);
      }

      XmlElement refNode = (XmlElement)projFile.SelectSingleNode("//References");

      if (refNode != null){
        referencesFolder = CreateNode(this, HierarchyNodeType.RefFolder, refNode);
        AddChild(referencesFolder);
        foreach (XmlElement e in refNode.SelectNodes("Reference")){
          HierarchyNode node = CreateNode(this, HierarchyNodeType.Reference, e);

          referencesFolder.AddChild(node);
        }
      }

      foreach (XmlElement e in this.projFile.SelectNodes("//Files/Include/File")){
        string strPath = e.GetAttribute("RelPath");
        uint itemId;
        HierarchyNode currentParent = this;

        strPath = Path.GetDirectoryName(strPath);
        if (strPath.Length > 0){
          // use the relative to verify the folders...
          CreateFolderNodes(strPath);
          // now create an absolute ouf of it
#if WHIDBEY
          Uri uri = new Uri(new Uri(this.projFile.BaseURI), strPath);
#else
          Uri uri = new Uri(new Uri(this.projFile.BaseURI), strPath, true);
#endif

          strPath = uri.LocalPath; //??? 
          strPath += "\\";
          this.ParseCanonicalName(strPath, out itemId);
          currentParent = this.NodeFromItemId(itemId);
        }

        currentParent.AddChild(this.CreateNode(this, HierarchyNodeType.File, e));
      }

      foreach (XmlElement e in this.projFile.SelectNodes("//Files/Include/Folder")){
        // so we do have some empty folders....
        string strPath = e.GetAttribute("RelPath");

        CreateFolderNodes(strPath);
      }

      SetProjectFileDirty(false);
      this.projFile.NodeChanged += new XmlNodeChangedEventHandler(OnNodeChanged);
      this.projFile.NodeInserted += new XmlNodeChangedEventHandler(OnNodeChanged);
      this.projFile.NodeRemoved += new XmlNodeChangedEventHandler(OnNodeChanged);

      RegisterSccProject();
    }
开发者ID:dbremner,项目名称:specsharp,代码行数:64,代码来源:Project.cs

示例10: AddDependentFileNodeToNode

 /// <summary>
 /// Add a dependent file node to the hierarchy
 /// </summary>
 /// <param name="item">msbuild item to add</param>
 /// <param name="parentNode">Parent Node</param>
 /// <returns>Added node</returns>
 private HierarchyNode AddDependentFileNodeToNode(MSBuild.BuildItem item, HierarchyNode parentNode)
 {
     FileNode node = this.CreateDependentFileNode(new ProjectElement(this, item, false));
     parentNode.AddChild(node);
     return node;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:12,代码来源:ProjectNode.cs

示例11: VerifySubFolderExists

        /// <summary>
        /// Takes a path and verifies that we have a node with that name.
        /// It is meant to be a helper method for CreateFolderNodes().
        /// For some scenario it may be useful to override.
        /// </summary>
        protected virtual FolderNode VerifySubFolderExists(string strPath, HierarchyNode parent)
        {
            FolderNode folderNode = null;
            uint uiItemId;
            Url url = new Url(this.BaseURI, strPath);
            string strFullPath = url.AbsoluteUrl;
            // Folders end in our storage with a backslash, so add one...
            ErrorHandler.ThrowOnFailure(this.ParseCanonicalName(strFullPath, out uiItemId));
            if (uiItemId != 0)
            {
                Debug.Assert(this.NodeFromItemId(uiItemId) is FolderNode, "Not a FolderNode");
                folderNode = (FolderNode)this.NodeFromItemId(uiItemId);
            }

            if (folderNode == null)
            {
                // folder does not exist yet...
                // We could be in the process of loading so see if msbuild knows about it
                MSBuild.BuildItemGroup folders = buildProject.GetEvaluatedItemsByName(ProjectFileConstants.Folder);
                ProjectElement item = null;
                foreach (MSBuild.BuildItem folder in folders)
                {
                    if (String.Compare(folder.FinalItemSpec.TrimEnd('\\'), strPath.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        item = new ProjectElement(this, folder, false);
                        break;
                    }
                }
                // If MSBuild did not know about it, create a new one
                if (item == null)
                    item = this.AddFolderToMsBuild(strPath);
                folderNode = this.CreateFolderNode(strPath, item);
                parent.AddChild(folderNode);
            }

            return folderNode;
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:42,代码来源:ProjectNode.cs

示例12: AddNewFileNodeToHierarchy

        /// <summary>
        /// Adds the new file node to hierarchy.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="fileName">Name of the file.</param>
        protected override void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string path)
        {
            // If a lua file is being added, try to find a related FrameXML node
            if (MultiverseInterfaceProjectNode.IsPythonFile(path))
            {
                // Try to find a FrameXML node with a matching relational name
                string fileName = Path.GetFileNameWithoutExtension(path);
                HierarchyNode childNode = this.FirstChild;

                // Iterate through the children
                while (childNode != null)
                {
                    // If this child is an XML node and its relational name matches, break out of the loop
                    if (childNode is MultiverseInterfaceXmlFileNode && String.Compare(childNode.GetRelationalName(), fileName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        parentNode = childNode;
                        break;
                    }

                    // Move over to the next sibling
                    childNode = childNode.NextSibling;
                }
            }

            HierarchyNode child;

            if (this.CanFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                child = this.CreateDependentFileNode(path);
                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (String.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(path);
            }

            parentNode.AddChild(child);

            this.Tracker.OnItemAdded(path, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:52,代码来源:MultiverseInterfaceProjectNode.cs


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