Udostępnij za pośrednictwem


Context and Subcontext Bags

Context and subcontext bags are COM objects, in this case IVsUserContext objects, that are used to group keywords and attributes associated with a particular context provider. A context provider is a component in the IDE, such as an editor, tool window, or language service, that is associated with a context bag. The context bag is an IVsUserContext object that supports methods for adding, removing, enumerating, and otherwise managing context. For more information about how to create a context bag, see How to: Create a Context Bag or Subcontext Bag. The context provider obtains a pointer to the CreateEmptyContext method. You can use this method to create a context bag by calling QueryService for the SVsMonitorUserContext service. The methods of IVsUserContext are also used to manage subcontext.

The subcontext bag is a separate IVsUserContext object that is linked to the context bag. The context for the component consists of its context bag together with any subcontext bags the context bag points to. Subcontext is associated with selections in editors, designers, tool windows and language services. Examples of subcontext include a key term in an editor or a command in a tool window. The union of the context and subcontext bags for each context provider in the active selection describes the overall context in the IDE at a particular time and is referred to as the active context collection. For more information, see Active Context.

The following illustration shows how context and subcontext bags are attached to components in the IDE.

Attaching context bags to IDE components

ContextBag graphic

For more information, see How to: Create a Context Bag or Subcontext Bag.

See Also

Concepts

Active Context

Reference

CreateEmptyContext

Other Resources

About Context-Sensitive Help