本文整理汇总了C#中IVsHierarchy.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IVsHierarchy.GetProperty方法的具体用法?C# IVsHierarchy.GetProperty怎么用?C# IVsHierarchy.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsHierarchy
的用法示例。
在下文中一共展示了IVsHierarchy.GetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollapseHierarchyItems
private void CollapseHierarchyItems(IVsUIHierarchyWindow toolWindow, IVsHierarchy hierarchy, uint itemid, bool hierIsSolution
, string[] captions)
{
IntPtr ptr;
uint num2;
Guid gUID = typeof(IVsHierarchy).GUID;
if ((hierarchy.GetNestedHierarchy(itemid, ref gUID, out ptr, out num2) == 0) && (IntPtr.Zero != ptr))
{
IVsHierarchy objectForIUnknown = Marshal.GetObjectForIUnknown(ptr) as IVsHierarchy;
Marshal.Release(ptr);
if (objectForIUnknown != null)
{
this.CollapseHierarchyItems(toolWindow, objectForIUnknown, num2, false, captions);
}
}
else
{
object obj2;
if (!hierIsSolution)
{
string canonicalname;
object captionobj;
hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_Caption, out captionobj);
var caption = (string)captionobj;
if (captions.Contains(caption))
{
hierarchy.GetCanonicalName(itemid, out canonicalname);
ErrorHandler.ThrowOnFailure(toolWindow.ExpandItem(hierarchy as IVsUIHierarchy, itemid, EXPANDFLAGS.EXPF_CollapseFolder));
}
}
if (hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_FirstVisibleChild, out obj2) == 0)
{
uint itemId = this.GetItemId(obj2);
while (itemId != uint.MaxValue)
{
this.CollapseHierarchyItems(toolWindow, hierarchy, itemId, false, captions);
int hr = hierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_NextVisibleSibling, out obj2);
if (hr == 0)
{
itemId = this.GetItemId(obj2);
}
else
{
ErrorHandler.ThrowOnFailure(hr);
return;
}
}
}
}
}
示例2: GetPropertyValue
public static object GetPropertyValue(int propid, uint itemId, IVsHierarchy vsHierarchy)
{
if (itemId == VSConstants.VSITEMID_NIL)
{
return null;
}
try
{
object o;
ErrorHandler.ThrowOnFailure(vsHierarchy.GetProperty(itemId, propid, out o));
return o;
}
catch (System.NotImplementedException)
{
return null;
}
catch (System.Runtime.InteropServices.COMException)
{
return null;
}
catch (System.ArgumentException)
{
return null;
}
}
示例3: VsSolutionHierarchyNode
internal VsSolutionHierarchyNode(IVsHierarchy hierarchy, uint itemId, Lazy<VsSolutionHierarchyNode> parent)
{
if (hierarchy == null)
throw new ArgumentNullException(nameof(hierarchy), $"{nameof(hierarchy)} is null.");
VsHierarchy = hierarchy;
ItemId = itemId;
IntPtr nestedHierarchyObj;
uint nestedItemId;
Guid hierGuid = typeof(IVsHierarchy).GUID;
// Check first if this node has a nested hierarchy. If so, then there really are two
// identities for this node: 1. hierarchy/itemid 2. nestedHierarchy/nestedItemId.
// We will recurse and call EnumHierarchyItems which will display this node using
// the inner nestedHierarchy/nestedItemId identity.
int hr = hierarchy.GetNestedHierarchy(itemId, ref hierGuid, out nestedHierarchyObj, out nestedItemId);
if (hr == VSConstants.S_OK && nestedHierarchyObj != IntPtr.Zero)
{
IVsHierarchy nestedHierarchy = Marshal.GetObjectForIUnknown(nestedHierarchyObj) as IVsHierarchy;
Marshal.Release(nestedHierarchyObj); // we are responsible to release the refcount on the out IntPtr parameter
if (nestedHierarchy != null)
{
VsHierarchy = nestedHierarchy;
ItemId = nestedItemId;
}
}
DisplayName = VsHierarchy.GetProperty<string>(__VSHPROPID.VSHPROPID_Name, ItemId);
m_parent = parent ?? new Lazy<VsSolutionHierarchyNode>(() =>
{
if (VsHierarchy is IVsSolution)
return null;
var rootHierarchy = hierarchy.GetProperty<IVsHierarchy>(__VSHPROPID.VSHPROPID_ParentHierarchy, VSConstants.VSITEMID_ROOT);
if (rootHierarchy == null)
return null;
var rootNode = new VsSolutionHierarchyNode(rootHierarchy, VSConstants.VSITEMID_ROOT);
var parentNode = new VsSolutionHierarchyNode[] { rootNode }
.Concat(rootNode.Children.BreadthFirstTraversal(node => node.Children))
.FirstOrDefault(node => node.Children.Any(child => child.ItemId == ItemId));
if (parentNode == null)
return null;
return new VsSolutionHierarchyNode(parentNode.VsHierarchy, parentNode.ItemId);
});
this.m_serviceProvider = new Lazy<IServiceProvider>(() =>
{
Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleSp;
hierarchy.GetSite(out oleSp);
return oleSp != null ?
new ServiceProvider(oleSp) :
GlobalVsServiceProvider.Instance;
});
}
示例4: GetProject
public static Project GetProject(IVsHierarchy hierarchy)
{
object project;
ErrorHandler.ThrowOnFailure(
hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out project));
return (Project)project;
}
示例5: GetEnvDTEProject
public static Project GetEnvDTEProject(IVsHierarchy hierarchy)
{
object prjObject;
hierarchy.GetProperty((uint) VSConstants.VSITEMID.Root, (int) __VSHPROPID.VSHPROPID_ExtObject, out prjObject);
return (Project) prjObject;
}
示例6: GetDteProject
public static Project GetDteProject(IVsHierarchy projectHierarchy)
{
object pvar;
int hr = projectHierarchy.GetProperty((uint)VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out pvar);
ErrorHandler.ThrowOnFailure(hr);
return (Project)pvar;
}
示例7: GetProject
public static EnvDTE.Project GetProject(IVsHierarchy hierarchy)
{
object obj = null;
if (hierarchy != null)
{
hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out obj);
}
return obj as EnvDTE.Project;
}
示例8: GetProjectFromHierarchy
public static Project GetProjectFromHierarchy(IVsHierarchy projectHierarchy)
{
object projectObject;
int result = projectHierarchy.GetProperty(
VSConstants.VSITEMID_ROOT,
(int)__VSHPROPID.VSHPROPID_ExtObject,
out projectObject);
ErrorHandler.ThrowOnFailure(result);
return (Project)projectObject;
}
示例9: ToDteProject
public static Project ToDteProject(IVsHierarchy hierarchy)
{
if (hierarchy == null)
throw new ArgumentNullException("hierarchy");
object prjObject;
if (hierarchy.GetProperty(0xfffffffe, -2027, out prjObject) >= 0)
return (Project)prjObject;
else
throw new ArgumentException("Hierarchy is not a project.");
}
示例10: GetProject
private static VSProject GetProject(IVsHierarchy hierarchy)
{
object projectObject;
if (ErrorHandler.Succeeded(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectObject)))
{
Project project = (Project) projectObject;
return (VSProject) project.Object;
}
return null;
}
示例11: GetItemIdInHierarchy
private static uint GetItemIdInHierarchy(IVsHierarchy hierarchy, uint itemid, string[] elementRelativePath, int recursionLevel)
{
int hr;
object pVar;
if (itemid != VSConstants.VSITEMID_ROOT)
{
hr = hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_Name, out pVar);
ErrorHandler.ThrowOnFailure(hr);
if ((string)pVar != elementRelativePath[recursionLevel - 1])
{
return VSConstants.VSITEMID_NIL;
}
else if (elementRelativePath.Length == recursionLevel)
{
return itemid;
}
}
//Get the first child node of the current hierarchy being walked
hr = hierarchy.GetProperty(itemid,
(int)__VSHPROPID.VSHPROPID_FirstChild,
out pVar);
ErrorHandler.ThrowOnFailure(hr);
if (VSConstants.S_OK == hr)
{
//We are using Depth first search so at each level we recurse to check if the node has any children
// and then look for siblings.
uint childId = GetItemId(pVar);
while (childId != VSConstants.VSITEMID_NIL)
{
uint returnedItemId = GetItemIdInHierarchy(hierarchy, childId, elementRelativePath,
recursionLevel + 1);
if (returnedItemId != VSConstants.VSITEMID_NIL)
{
return returnedItemId;
}
hr = hierarchy.GetProperty(childId,
(int)__VSHPROPID.VSHPROPID_NextSibling,
out pVar);
if (VSConstants.S_OK == hr)
{
childId = GetItemId(pVar);
}
else
{
ErrorHandler.ThrowOnFailure(hr);
break;
}
}
}
return VSConstants.VSITEMID_NIL;
}
示例12: GetProject
public Project GetProject(IVsHierarchy hierarchy)
{
object project;
ErrorHandler.ThrowOnFailure
(hierarchy.GetProperty(
(uint)VSConstants.VSITEMID.Root,
(int)__VSHPROPID.VSHPROPID_ExtObject,
out project));
return (project as Project);
}
示例13: GetPropertyValue
private static object GetPropertyValue(int propid, uint itemId, IVsHierarchy vsHierarchy) {
if (itemId == VSConstants.VSITEMID_NIL) {
return null;
}
object o;
if (ErrorHandler.Failed(vsHierarchy.GetProperty(itemId, propid, out o))) {
return null;
}
return o;
}
示例14: GetProjectItem
public ProjectItem GetProjectItem(IVsHierarchy hierarchy, UInt32 prjItemId)
{
object prjItemObject = null;
if (
ErrorHandler.Succeeded(hierarchy.GetProperty(prjItemId, (int)__VSHPROPID.VSHPROPID_ExtObject,
out prjItemObject)))
{
return prjItemObject as ProjectItem;
}
return null;
}
示例15: OnAfterRenameProject
public override int OnAfterRenameProject(IVsHierarchy hierarchy)
{
if (hierarchy == null)
{
return VSConstants.E_INVALIDARG;
}
try
{
List<ProjectReferenceNode> projectReferences = this.GetProjectReferencesContainingThisProject(hierarchy);
// Collect data that is needed to initialize the new project reference node.
string projectRef;
ErrorHandler.ThrowOnFailure(this.Solution.GetProjrefOfProject(hierarchy, out projectRef));
object nameAsObject;
ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Name, out nameAsObject));
string projectName = (string)nameAsObject;
string projectPath = String.Empty;
if (hierarchy is IVsProject3)
{
IVsProject3 project = (IVsProject3)hierarchy;
ErrorHandler.ThrowOnFailure(project.GetMkDocument(VSConstants.VSITEMID_ROOT, out projectPath));
projectPath = Path.GetDirectoryName(projectPath);
}
// Remove and re add the node.
foreach (ProjectReferenceNode projectReference in projectReferences)
{
ProjectNode projectMgr = projectReference.ProjectMgr;
IReferenceContainer refContainer = projectMgr.GetReferenceContainer();
projectReference.Remove(false);
VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA();
selectorData.type = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project;
selectorData.bstrTitle = projectName;
selectorData.bstrFile = projectPath;
selectorData.bstrProjRef = projectRef;
refContainer.AddReferenceFromSelectorData(selectorData);
}
}
catch (COMException e)
{
Trace.WriteLine("Exception :" + e.Message);
return e.ErrorCode;
}
return VSConstants.S_OK;
}