IVsUserContext.GetAttribute Method
Returns the specified attribute or keyword from the context or subcontext bag based on index position or name.
Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)
Syntax
声明
Function GetAttribute ( _
iAttribute As Integer, _
pszName As String, _
fIncludeChildren As Integer, _
<OutAttribute> ByRef pbstrName As String, _
<OutAttribute> ByRef pbstrValue As String _
) As Integer
用法
Dim instance As IVsUserContext
Dim iAttribute As Integer
Dim pszName As String
Dim fIncludeChildren As Integer
Dim pbstrName As String
Dim pbstrValue As String
Dim returnValue As Integer
returnValue = instance.GetAttribute(iAttribute, _
pszName, fIncludeChildren, pbstrName, _
pbstrValue)
int GetAttribute(
int iAttribute,
string pszName,
int fIncludeChildren,
out string pbstrName,
out string pbstrValue
)
int GetAttribute(
[InAttribute] int iAttribute,
[InAttribute] String^ pszName,
[InAttribute] int fIncludeChildren,
[OutAttribute] String^% pbstrName,
[OutAttribute] String^% pbstrValue
)
abstract GetAttribute :
iAttribute:int *
pszName:string *
fIncludeChildren:int *
pbstrName:string byref *
pbstrValue:string byref -> int
function GetAttribute(
iAttribute : int,
pszName : String,
fIncludeChildren : int,
pbstrName : String,
pbstrValue : String
) : int
Parameters
- iAttribute
Type: System.Int32
[in] Index into the collection of attributes and keywords in the context or subcontext bag.
- pszName
Type: System.String
[in] Attribute name or keyword. Specify the attribute name to access a specific attribute. Specify "keyword" to access an F1 or lookup keyword.
- fIncludeChildren
Type: System.Int32
[in] If true, then the subcontext bags associated with the context bag are also returned. If false, then the subcontext is excluded.
- pbstrName
Type: System.String%
[out] Pointer to the specific attribute name or the value keyword, if a match is found.
- pbstrValue
Type: System.String%
[out, retval] Pointer to the specific attribute value or the keyword text, if a match is found.
Return Value
Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Remarks
COM Signature
From context.idl:
HRESULT IVsUserContext::GetAttribute(
[in] int iAttribute,
[in] LPCOLESTR pszName,
[in] BOOL fIncludeChildren,
[out] BSTR * pbstrName,
[out, retval] BSTR * pbstrValue
);
There are three different ways to use the IVsUserContext.GetAttribute method:
Pass in nulla null reference (Nothing in Visual Basic) for the value of the pszName parameter and iterate through all of the attributes and keywords in the context bag using the iAttribute parameter. You can determine the count of attributes and keywords in the context or subcontext bag using the CountAttributes method.
Iterate through all of the attributes and keywords and pass in a specific attribute name or keyword for the value of the pszName parameter. An attribute name and value or keyword and value are returned in the pbstrName and pbstrValue parameters, respectively, only if the name you provided matched the name in the context or subcontext bag.
Pass in a value of -1 for the iAttribute parameter and a specific attribute name or keyword for the value of the pszName parameter. The first attribute or keyword that matches the name is returned.
If this method finds a match for the pszName parameter, then it returns S_OK. If the method does not find a match, then it returns E_UNEXPECTED. Thus, it is possible to set the values of the *pbstrName and *pbstrValue parameters to nulla null reference (Nothing in Visual Basic) and evaluate the success or failure of the method based on the return values.
Use the GetAttributePri method to access attributes or keywords based on their priority. For more information about priority, see VSUSERCONTEXTPRIORITY. Use the GetAttrUsage method to determine whether a keyword returned from the IVsUserContext::GetAttribute method is an F1 or lookup keyword.
The value of the fIncludeChildren parameter has no effect if the context bag does not have any subcontext.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.