Udostępnij za pośrednictwem


IVsUserContext.GetAttribute(Int32, String, Int32, String, String) Method

Definition

Returns the specified attribute or keyword from the context or subcontext bag based on index position or name.

public:
 int GetAttribute(int iAttribute, System::String ^ pszName, int fIncludeChildren, [Runtime::InteropServices::Out] System::String ^ % pbstrName, [Runtime::InteropServices::Out] System::String ^ % pbstrValue);
int GetAttribute(int iAttribute, std::wstring const & pszName, int fIncludeChildren, [Runtime::InteropServices::Out] std::wstring const & & pbstrName, [Runtime::InteropServices::Out] std::wstring const & & pbstrValue);
public int GetAttribute (int iAttribute, string pszName, int fIncludeChildren, out string pbstrName, out string pbstrValue);
abstract member GetAttribute : int * string * int * string * string -> int
Public Function GetAttribute (iAttribute As Integer, pszName As String, fIncludeChildren As Integer, ByRef pbstrName As String, ByRef pbstrValue As String) As Integer

Parameters

iAttribute
Int32

[in] Index into the collection of attributes and keywords in the context or subcontext bag.

pszName
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
Int32

[in] If true, then the subcontext bags associated with the context bag are also returned. If false, then the subcontext is excluded.

pbstrName
String

[out] Pointer to the specific attribute name or the value keyword, if a match is found.

pbstrValue
String

[out, retval] Pointer to the specific attribute value or the keyword text, if a match is found.

Returns

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 null 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 null 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.

Applies to