Package Class
Provides a managed implementation of the interfaces required to create a fully functional VSPackage.
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.Shell.Package
Microsoft.VisualStudio.Shell.ExtensionPointPackage
Namespace: Microsoft.VisualStudio.Shell
Assembly: Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)
Syntax
'Declaração
<ComVisibleAttribute(True)> _
<PackageRegistrationAttribute> _
Public MustInherit Class Package _
Implements IVsPackage, IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts, _
IServiceContainer, IServiceProvider, IVsUserSettings, IVsUserSettingsMigration, IVsUserSettingsQuery, _
IVsToolWindowFactory, IVsToolboxItemProvider
[ComVisibleAttribute(true)]
[PackageRegistrationAttribute]
public abstract class Package : IVsPackage,
IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts, IServiceContainer, IServiceProvider,
IVsUserSettings, IVsUserSettingsMigration, IVsUserSettingsQuery, IVsToolWindowFactory, IVsToolboxItemProvider
The Package type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Package | Initializes a new instance of Package. |
Top
Properties
Name | Description | |
---|---|---|
ApplicationRegistryRoot | Gets the root registry key of the current Visual Studio registry hive. | |
UserDataPath | Gets the path to user data storage for Visual Studio. | |
UserLocalDataPath | Gets the path to local user data storage for Visual Studio. | |
UserRegistryRoot | Gets a registry key that can be used to store user data. | |
Zombied | Gets a value indicating whether the package in the process of shutdown. |
Top
Methods
Name | Description | |
---|---|---|
AddOptionKey | Adds a user option key name into the list of option keys. | |
CreateInstance | Creates the specified COM object using the Visual Studio's local registry CLSID object. | |
CreateTool | Enables derived classes to provide an implementation if necessary. | |
CreateToolWindow | Creates a tool window of the specified type with the specified ID. | |
Dispose | Releases the resources used by the Package object. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FindToolWindow | Gets the tool window corresponding to the specified type and ID. | |
FindWindowPane | Gets the window pane corresponding to the specified type and ID, and if no window pane of that type exists creates one if told to do so. | |
GetAutomationObject | Gets the automation object for the VSPackage. | |
GetDialogPage | Gets the requested dialog page. | |
GetGlobalService | Gets a service proffered globally by Visual Studio or one of its packages. This is the same as calling GetService() on an instance of a package that proffers no services itself. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetOutputPane | Gets the requested output window. | |
GetProviderLocale | Returns the locale associated with this service provider. | |
GetService | Gets type-based services from the VSPackage service container. | |
GetToolboxItemData | Gets the content of the data format for the specified toolbox item ID and data format. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Initialize | Called when the VSPackage is loaded by Visual Studio. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnLoadOptions | Invoked by the package class when there are options to be read out of the solution file. | |
OnSaveOptions | Invoked by the Package class when there are options to be saved to the solution file. | |
ParseToolboxResource(TextReader, Guid) | Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox. | |
ParseToolboxResource(TextReader, ResourceManager) | Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox. | |
QueryClose | Called to ask the package if the shell can be closed. | |
RegisterEditorFactory | Registers an editor factory with Visual Studio. | |
RegisterProjectFactory | Registers a project factory with Visual Studio. | |
ShowOptionPage | Displays a specified tools options page. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
ToolboxInitialized | Event generated whenever Visual Studio initializes its Toolbox. | |
ToolboxUpgraded | Event generated whenever Visual Studio upgrades its Toolbox. |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
IServiceContainer.AddService(Type, ServiceCreatorCallback) | Infrastructure. Adds the given service to the VSPackage's service container. | |
IServiceContainer.AddService(Type, Object) | Infrastructure. Adds the given service to the VSPackage's service container. | |
IServiceContainer.AddService(Type, ServiceCreatorCallback, Boolean) | Adds the given service to the service container by means of the specified ServiceCreatorCallback. | |
IServiceContainer.AddService(Type, Object, Boolean) | Infrastructure. Adds the given service to the VSPackage's service container. | |
IServiceProvider.GetService | Gets the service of the specified type. | |
IServiceContainer.RemoveService(Type) | Infrastructure. Removes the given service type from the service container. | |
IServiceContainer.RemoveService(Type, Boolean) | Infrastructure. Removes the given service type from the service container, and optionally promotes the removal of the service to parent service containers. | |
IOleCommandTarget.Exec | Executes a specified command or displays help for a command. | |
IOleCommandTarget.QueryStatus | Queries the object for the status of one or more commands generated by user interface events. | |
IServiceProvider.QueryService | Infrastructure. Internal IServiceProvider implementation. | |
IVsPackage.Close | Infrastructure. Closes and disposes the package. | |
IVsPackage.GetAutomationObject | Infrastructure. Gets an automation-friendly object for this package. | |
IVsPackage.GetPropertyPage | Infrastructure. Proffers access to the Tools menu Options and the property pages of the Customize Toolbox dialog boxes. | |
IVsPackage.QueryClose | Infrastructure. Called to ask the VSPackage if the Visual Studio shell can be closed. | |
IVsPackage.ResetDefaults | Infrastructure. Resets Toolbox defaults. | |
IVsPackage.SetSite | Infrastructure. Initializes the VSPackage in the Visual Studio environment. | |
IVsPersistSolutionOpts.LoadUserOptions | Infrastructure. Loads user options for a given solution. | |
IVsPersistSolutionOpts.ReadUserOptions | Infrastructure. Reads user options for a given solution. | |
IVsPersistSolutionOpts.SaveUserOptions | Infrastructure. Saves user options for a given solution. | |
IVsPersistSolutionOpts.WriteUserOptions | Infrastructure. Writes user options for a given solution. | |
IVsToolboxItemProvider.GetItemContent | Gets an item. | |
IVsToolWindowFactory.CreateToolWindow | Infrastructure. Creates a tool window of the specified type with the specified ID. | |
IVsUserSettings.ExportSettings | This method implements the IVsUserSettings Interface used to manage profiles and import/export settings to XML files. | |
IVsUserSettings.ImportSettings | Retrieves a VSPackage's configuration using the Visual Studio settings mechanism when a user selects the import option of the Import/Export Settings feature on the IDE’s Tools menu. This method is part of the implementation of the IVsUserSettings interface used to manage profiles and import/export settings to XML files. | |
IVsUserSettingsMigration.MigrateSettings | Migrates settings from a previous version. | |
IVsUserSettingsQuery.NeedExport |
Top
Remarks
The Package class provides a managed implementation of several of the most useful VSIP interfaces. You can create the basic functionality of a VSPackage with relatively little code by deriving from the Package class, overriding some of its methods, and attaching registration attribute classes. The Package class does not provide direct registration support, but it can use attribute classes to supply the necessary registration information to external tools such as RegPkg.exe.
The Package class offers the following services by default. (You can replace them by asking the VSPackage for IServiceContainer, removing them, and adding your own services in their place.)
Package
The package offers itself as a service.
-
Provides the ability to add and remove services. Any service added with "promote" set to true is proffered to Visual Studio through IProfferService. This makes the service global to all VSPackages within Visual Studio. (This service is available only if the VSPackage has already been loaded.)
In addition to these services, Package uses the service architecture of Visual Studio to provide access to any service available through the global service provider.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
Microsoft.VisualStudio.Shell Namespace