Share via


ProvideProfileAttribute Class

Definition

Apply this attribute to independent objects used to implement a VSPackage's Visual Studio settings support.

public ref class ProvideProfileAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttribute
public ref class ProvideProfileAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
public sealed class ProvideProfileAttribute : Microsoft.VisualStudio.Shell.RegistrationAttribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)>]
type ProvideProfileAttribute = class
    inherit RegistrationAttribute
Public NotInheritable Class ProvideProfileAttribute
Inherits RegistrationAttribute
Inheritance
ProvideProfileAttribute
Attributes

Examples

In the example below, two instances of ProvideProfileAttribute are applied to a VSPackage implementation to define the two classes as providing Visual Studio settings support for the VSPackage implemented by the class MyPackage.

  1. Because the implementation of the page named "DesignerOptionsPage" is derived from DialogPage, it can support Visual Studio settings and Tools Options pages, and is registered as providing both:

    • An implementation of a Tools Options page, which is registered through the instance ProvideOptionPageAttribute. For more information on supporting Tools Options pages, see ProvideOptionPageAttribute.

    • An implementation that supports persisting the state of Tools Options pages, which is indicated by the final argument to the ProvideProfileAttribute constructor.

  2. The class named "PersistedDesignerState" is registered as providing just Visual Studio settings support, saving and retrieving remaining state information of the VSPackage named "MyPackage" by implementing IProfileManager.

using Microsoft.VisualStudio.Shell;  
namespace Example  
{  
[DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\8.0")]   
[ProvideOptionPage(typeof(DesignerOptionsPage), "MyDesigner", "OptionPage", 1000, 1001, true)]   
[ProvideProfileAttribute(typeof(DesignerOptionsPage), "MyDesigner", "OptionPage", 1002, 1003, true)]  
[ProvideProfileAttribute(typeof(PersistCurrentDesign), "MyDesigner","CurrentDesign", 1004, 1005, false)]  
[Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]  
public class MyPackage : Package  
{  
//Implementation here  
}  

[Guid("YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY")]  
internal class DesignerOptionsPage: DialogPage {  
//Implementation here  
}  

[Guid("ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ")]  
internal class PersistCurrentDesign: IProfileManager {  
//Implementation here  
}  

Remarks

Notes for Callers

Apply the ProvideProfileAttribute attribute to classes implementing a VSPackage when there is a class that implements Visual Studio settings functionality for the VSPackage, allowing it to save and retrieve VSPackage state information.

Note

Classes implementing IProfileManager, must also implement IComponent, which can be done by deriving the class from Component.

Attribute Context

Applies to VSPackages using the Visual Studio settings mechanism through classes that implement the IProfileManager or DialogPage interfaces.
Repeatable Yes
Required attributes DefaultRegistryRootAttribute, Note If the class implementing Visual Studio settings also provides a Tools Options page, ProvideOptionPageAttribute is also required.
Invalid attributes None

Notes for Implementers

This attribute is used only for registration purposes and does not affect runtime behavior.

ProvideProfileAttribute registers a class implementing IProfileManager or DialogPage as providing support for persisting part or all of the VSPackage's state through the Visual Studio settings mechanism. The state information persisted by the implementing class is referred to as a Visual Studio settings category, and its defining entry in the registry is referred to as a Custom Settings Point.

When a user selects the Import/Export Settings command on the Tools menu to save Visual Studio settings, the classes registered by ProvideProfileAttribute are instantiated by the IDE and used to save the settings.

Because of this:

  • Visual Studio settings support should be implemented on its own object and not on the VSPackage itself.

  • A class implementing Visual Studio settings may support only one Visual Studio settings category as defined in Custom Settings Point.

However, a single VSPackage may support several Visual Studio settings categories as defined multiple Custom Settings Points as long as:

  • Each Visual Studio settings category is implemented in a separate class..

  • Each class implementing Visual Studio settings is registered as supporting the VSPackage by its own instance of ProvideProfileAttribute.

    Note

    This differs from the COM-based implementations where a class implementing Visual Studio settings may support multiple Custom Settings Points.

An instance of ProvideProfileAttribute:

  • Uniquely identifies a Custom Settings Point's Visual Studio settings category with the GUID obtained from the Type of the class implementing Visual Studio settings.

  • Sets a Visual Studio settings category's name, both its canonical, nonlocalized name used in registry entries and its localized name resources.

  • Indicates if the Visual Studio settings supporting class's implementation of ProvideProfileAttribute supports a Tools Options page (for more information on supporting Tools Options page, see Options Pages).

For more information on creating and applying instances of ProvideProfileAttribute, see the example below and ProvideProfileAttribute.

Constructors

ProvideProfileAttribute(Type, String, String, Int16, Int16, Boolean)

Initializes a new instance of ProvideProfileAttribute.

Properties

AlternateParent

Gets or sets the name of a different category in the profile.

CategoryName

Gets the canonical nonlocalized name of the Visual Studio settings category.

CategoryResourceID

Gets the name resource ID for a Visual Studio settings category.

DescriptionResourceID

Gets the localized resource ID of the description of this page of the profile.

GroupName

Gets the nonlocalized name of this group.

GroupResourceID

Gets or sets the localized resource ID of the group to which this page belongs.

IsToolsOptionPage

Gets whether this is also a Tools Options page.

MigrationType

Sets the migration action to take for this category.

ObjectName

Gets the canonical nonlocalized name of this page in the profile.

ObjectNameResourceID

Gets the localized resource ID of the name of this page in the profile.

ObjectType

Gets the type of the page.

ResourcePackageGuid

Gets or sets the GUID of a package providing the resource strings.

TypeId

Override the TypeID property in order to let the RegistrationAttribute derived classes to work with System.ComponentModel.TypeDescriptor.GetAttributes(...). An attribute derived from this one will have to override this property only if it needs a better control on the instances that can be applied to a class.

(Inherited from RegistrationAttribute)

Methods

GetPackageRegKeyPath(Guid)

Gets the registry path (relative to the registry root of the application) of the VSPackage.

(Inherited from RegistrationAttribute)
Register(RegistrationAttribute+RegistrationContext)

Registers this attribute.

Unregister(RegistrationAttribute+RegistrationContext)

Removes the key from the registry.

Applies to