IVsUserContext.GetAttribute 方法

返回指定的属性或关键字根据索引位置或名称的上下文或 subcontext 包。

命名空间:  Microsoft.VisualStudio.Shell.Interop
程序集:  Microsoft.VisualStudio.Shell.Interop(在 Microsoft.VisualStudio.Shell.Interop.dll 中)

语法

声明
Function GetAttribute ( _
    iAttribute As Integer, _
    pszName As String, _
    fIncludeChildren As Integer, _
    <OutAttribute> ByRef pbstrName As String, _
    <OutAttribute> ByRef pbstrValue As String _
) As Integer
int GetAttribute(
    int iAttribute,
    string pszName,
    int fIncludeChildren,
    out string pbstrName,
    out string pbstrValue
)

参数

  • iAttribute
    类型:System.Int32
    [in] 索引到属性和关键字中的集合在上下文或 subcontext 包。
  • pszName
    类型:System.String
    [in] 属性名称或关键字。指定属性名称来访问该特定属性。指定 “关键字”访问 F1 或查找关键字。
  • fIncludeChildren
    类型:System.Int32
    [in] 如果 true, subcontext 包与上下文关联的包还然后返回。如果 false, subcontext 然后被排除。
  • pbstrName
    类型:System.String%
    [out] 对特定的属性名称或值关键字的指针,因此,如果找到匹配。
  • pbstrValue
    类型:System.String%
    [out, retval] 对特定属性值或关键字文本的指针,因此,如果找到匹配。

返回值

类型:System.Int32
如果方法成功,则返回 S_OK。如果失败,它会返回一个错误代码。

备注

COM 签名

从 context.idl:

HRESULT IVsUserContext::GetAttribute(
   [in] int iAttribute,
   [in] LPCOLESTR pszName,
   [in] BOOL fIncludeChildren,
   [out] BSTR * pbstrName,
   [out, retval] BSTR * pbstrValue
);

有三种不同的方式使用 IVsUserContext.GetAttribute 方法:

  • 通过在 pszName 参数的值 nullnull 引用(在 Visual Basic 中为 Nothing) 并将所有属性重复使用 iAttribute 参数,因此,关键字在上下文请求。使用 CountAttributes 方法,可确定计数属性和关键字在上下文或 subcontext 包。

  • 通过所有属性和关键字重复并传入特定属性名称或关键字 pszName 参数的值。特性名和值或关键字和值。 pbstrName 和 pbstrValue 参数返回,分别,因此,只有当提供的名称与了上下文或 subcontext 包的名称。

  • 通过按值为 -1 iAttribute 参数的和一个特定的属性名称或关键字 pszName 参数的值。与该名称的第一个属性或关键字返回。

如果此方法可查找 pszName 参数匹配,则返回 S_OK。如果方法未找到匹配项,则返回 E_UNEXPECTED。因此,设置 *pbstrName 和 * 是可能的pbstrValue参数的值传递给 nullnull 引用(在 Visual Basic 中为 Nothing) 和计算基于方法返回值的成功或失败。

使用 GetAttributePri 方法根据它们的优先级别或关键字的属性。有关优先级的更多信息,请参见 VSUSERCONTEXTPRIORITY。使用 GetAttrUsage 方法确定从 IVsUserContext::GetAttribute 方法返回的关键字是否 F1 或查找关键字。

,如果上下文包没有任何 subcontext, fIncludeChildren 参数的值不起作用。

.NET Framework 安全性

请参见

参考

IVsUserContext 接口

Microsoft.VisualStudio.Shell.Interop 命名空间