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


C# IVsHierarchy.?.GetProperty方法代码示例

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


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

示例1: GetProjectItems

        public static async Task<IList<uint>> GetProjectItems(IVsHierarchy pHier, uint startItemid)
        {
            List<uint> projectNodes = new List<uint>();

            //if (pHier == null)
            //{
            //    return projectNodes;
            //}

            // The method does a breadth-first traversal of the project's hierarchy tree
            Queue<uint> nodesToWalk = new Queue<uint>();
            nodesToWalk.Enqueue(startItemid);

            while (nodesToWalk.Count > 0)
            {
                uint node = nodesToWalk.Dequeue();
                projectNodes.Add(node);

                // DebugWalkingNode(pHier, node);
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                object property = null;
                if (pHier?.GetProperty(node, (int)__VSHPROPID.VSHPROPID_FirstChild, out property) == VSConstants.S_OK)
                {
                    uint childnode = (uint)(int)property;
                    if (childnode == VSConstants.VSITEMID_NIL)
                    {
                        continue;
                    }

                   // DebugWalkingNode(pHier, childnode);

                    if ((pHier.GetProperty(childnode, (int)__VSHPROPID.VSHPROPID_Expandable, out property) == VSConstants.S_OK && (int)property != 0) ||
                        (pHier.GetProperty(childnode, (int)__VSHPROPID2.VSHPROPID_Container, out property) == VSConstants.S_OK && (bool)property))
                    {
                        nodesToWalk.Enqueue(childnode);
                    }
                    else
                    {
                        projectNodes.Add(childnode);
                    }

                    while (pHier.GetProperty(childnode, (int)__VSHPROPID.VSHPROPID_NextSibling, out property) == VSConstants.S_OK)
                    {
                        childnode = (uint)(int)property;
                        if (childnode == VSConstants.VSITEMID_NIL)
                        {
                            break;
                        }

                        //DebugWalkingNode(pHier, childnode);
                        //TODO exception to fix here
                        var propertyCache = pHier.GetProperty(childnode, (int) __VSHPROPID.VSHPROPID_Expandable,
                            out property);
                        object property2 = null;
                        var propertyCache2 = pHier.GetProperty(childnode, (int)__VSHPROPID.VSHPROPID_Name,
                          out property2);
                        if ((pHier.GetProperty(childnode, (int)__VSHPROPID.VSHPROPID_Expandable, out property) == VSConstants.S_OK && (int)property != 0) ||
                            (pHier.GetProperty(childnode, (int)__VSHPROPID2.VSHPROPID_Container, out property) == VSConstants.S_OK && (bool)property))
                        {
                            nodesToWalk.Enqueue(childnode);
                        }
                        else
                        {
                            projectNodes.Add(childnode);
                        }
                    }
                }

            }

            return projectNodes;
        }
开发者ID:annastazi09,项目名称:Git-Source-Control-Provider,代码行数:72,代码来源:SolutionExtensions.cs

示例2:

        int IVsUpdateSolutionEvents.OnActiveProjectCfgChange(IVsHierarchy pIVsHierarchy)
        {
            // This method is called if the user is changing solution or project configuration e.g. from Debug to Release.
            // Also if a new solution config was created.
            // This method is called for each Hierarchy element (e.g. project and folders), thus we filter for the startup project
            // to only trigger the config changed event once.

            object objProj = null;
            pIVsHierarchy?.GetProperty(VSConstants.VSITEMID_ROOT,
                                       (int)__VSHPROPID.VSHPROPID_ExtObject,
                                       out objProj);

            EnvDTE.Project project = objProj as EnvDTE.Project;

            if (project?.UniqueName == StartupProjectUniqueName())
            {
                StartupProjectConfigurationChanged?.Invoke(this, EventArgs.Empty);
            }

            return S_OK;
        }
开发者ID:MBulli,项目名称:SmartCommandlineArgs,代码行数:21,代码来源:VisualStudioHelper.cs


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