다음을 통해 공유


IVsUserContext Interface

Definition

Manages attributes and keywords (context and subcontext) in the context or subcontext bag.

public interface class IVsUserContext
public interface class IVsUserContext
__interface IVsUserContext
[System.Runtime.InteropServices.Guid("761081DF-D45F-4683-9B9E-1B7241E56F5C")]
[System.Runtime.InteropServices.InterfaceType(1)]
public interface IVsUserContext
[System.Runtime.InteropServices.Guid("761081DF-D45F-4683-9B9E-1B7241E56F5C")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
public interface IVsUserContext
[<System.Runtime.InteropServices.Guid("761081DF-D45F-4683-9B9E-1B7241E56F5C")>]
[<System.Runtime.InteropServices.InterfaceType(1)>]
type IVsUserContext = interface
[<System.Runtime.InteropServices.Guid("761081DF-D45F-4683-9B9E-1B7241E56F5C")>]
[<System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)>]
type IVsUserContext = interface
Public Interface IVsUserContext
Attributes

Remarks

Context and subcontext are comprised of F1 keywords, lookup keywords, and attributes. Context and subcontext bags are COM objects (IVsUserContext objects) that are used to group keywords and attributes associated with a particular context provider. Context providers are environment components that are involved in selection, such as tool windows, editors, and language services. Subcontext is a selection within an editor, tool window or language service. Examples of subcontext elements include a key language term in a language service or a command in a tool window.

The context provider associates the context bag with the selection. The subcontext bag is a separate IVsUserContext object that is linked to the context bag. Because the context bag points to any subcontext bags that are linked to it, the keywords and attributes present in both the context and subcontext bags comprise the entire context for the component. The union of the context and subcontext bags for each context provider within the active selection describes the overall context in the environment at a particular time.

Before you can use the methods of IVsUserContext to manage the context bag, you first need to set up the environment component as a context provider by creating a context bag for it. To create a new context bag, call QueryService on the SVsMonitorUserContext service to get a pointer to the IVsMonitorUserContext interface. Once you have the pointer to this interface, call CreateEmptyContext to create a new context bag and to receive a pointer to IVsUserContext. You can then call the AddAttribute method to add attributes, lookup keywords, or F1 keywords to the context bag. Use this same procedure to create and populate a subcontext bag, and then call AddSubcontext to link the subcontext bag to the context bag.

Notes to Callers

Call this interface to add, remove, enumerate, or flag context and subcontext.

Methods

AddAttribute(VSUSERCONTEXTATTRIBUTEUSAGE, String, String)

Adds an attribute, lookup keyword, or F1 keyword to the context or subcontext bag.

AddSubcontext(IVsUserContext, Int32, UInt32)

Links a subcontext bag to a parent context bag.

AdviseUpdate(IVsUserContextUpdate, UInt32)

Enables clients to receive notification when the user context property bag is changed.

CountAttributes(String, Int32, Int32)

Returns the number of attributes or keywords present in the context or subcontext bag.

CountSubcontexts(Int32)

Returns the number of subcontext bags associated with the context bag.

GetAttribute(Int32, String, Int32, String, String)

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

GetAttributePri(Int32, String, Int32, Int32, String, String)

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

GetAttrUsage(Int32, Int32, VSUSERCONTEXTATTRIBUTEUSAGE[])

Returns the type of context (attribute, lookup keyword, or F1 keyword) that is present at a specified index position in the context or subcontext bag.

GetPriority(Int32)

Determines the priority of an attribute or keyword in the context or subcontext bag.

GetSubcontext(Int32, IVsUserContext)

Returns a specified subcontext bag from the parent context bag.

IsDirty(Int32)

Determines whether the user context has changed in the context or subcontext bag.

RemoveAllSubcontext()

Removes all subcontext bags associated with the context bag.

RemoveAttribute(String, String)

Removes an attribute or keyword from a context or subcontext bag.

RemoveAttributeIncludeChildren(String, String)

Removes an attribute or keyword from the context bag and from any associated subcontext bags.

RemoveSubcontext(UInt32)

Removes the specified subcontext bag.

SetDirty(Int32)

Flags the context or subcontext bag for update.

UnadviseUpdate(UInt32)

Disables clients from receiving notification of updates to the user context.

Update()

Updates user context.

Applies to