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