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


C# IVsHierarchy.GetProperty方法代码示例

本文整理汇总了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;
                 }
             }
         }
     }
 }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:50,代码来源:CollapseFoldersCommand.cs

示例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;
            }
        }
开发者ID:midwinterfs,项目名称:TSTestExtension,代码行数:27,代码来源:VsSolutionHelper.cs

示例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;
         });
      }
开发者ID:modulexcite,项目名称:AlphaVSX,代码行数:60,代码来源:VsSolutionHierarchyNode.cs

示例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;
 }
开发者ID:saint1729,项目名称:caide,代码行数:7,代码来源:SolutionUtilities.cs

示例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;
        }
开发者ID:mpartipilo,项目名称:SonarCompanion,代码行数:8,代码来源:VsInteropUtilities.cs

示例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;
        }
开发者ID:Azure,项目名称:azure-iot-hub-vs-cs,代码行数:8,代码来源:ProjectUtilities.cs

示例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;
 }
开发者ID:alux-xu,项目名称:ice-builder-visualstudio,代码行数:9,代码来源:DTEUtil.cs

示例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;
 }
开发者ID:grazies,项目名称:VSOnlineConnectedService,代码行数:10,代码来源:ProjectHelper.cs

示例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.");
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:10,代码来源:VsHelper.cs

示例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;
		}
开发者ID:modulexcite,项目名称:xbuilder,代码行数:10,代码来源:VsHelper.cs

示例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;
        }
开发者ID:attilah,项目名称:ProjectLinker,代码行数:55,代码来源:HierarchyHelper.cs

示例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);
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:11,代码来源:RdtManager.cs

示例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;
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:11,代码来源:Extensions.cs

示例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;
 }
开发者ID:divyang4481,项目名称:REM,代码行数:11,代码来源:GhostDocPackagePackage.cs

示例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;
        }
开发者ID:zooba,项目名称:wix3,代码行数:52,代码来源:solutionlistenerforprojectreferenceupdate.cs


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