Share via


ProvideProfileAttribute Class

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

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideProfileAttribute

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideProfileAttribute _
    Inherits RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideProfileAttribute : RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideProfileAttribute sealed : public RegistrationAttribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideProfileAttribute =  
    class 
        inherit RegistrationAttribute 
    end
public final class ProvideProfileAttribute extends RegistrationAttribute

The ProvideProfileAttribute type exposes the following members.

Constructors

  Name Description
Public method ProvideProfileAttribute Initializes a new instance of ProvideProfileAttribute.

Top

Properties

  Name Description
Public property AlternateParent Gets or sets the name of a different category in the profile.
Public property CategoryName Gets the canonical nonlocalized name of the Visual Studio settings category.
Public property CategoryResourceID Gets the name resource ID for a Visual Studio settings category.
Public property DescriptionResourceID Gets the localized resource ID of the description of this page of the profile.
Public property GroupName Gets the nonlocalized name of this group.
Public property GroupResourceID Gets or sets the localized resource ID of the group to which this page belongs.
Public property IsToolsOptionPage Gets whether this is also a Tools Options page.
Public property MigrationType Sets the migration action to take for this category.
Public property ObjectName Gets the canonical nonlocalized name of this page in the profile.
Public property ObjectNameResourceID Gets the localized resource ID of the name of this page in the profile.
Public property ObjectType Gets the type of the page.
Public property ResourcePackageGuid Gets or sets the GUID of a package providing the resource strings.
Public property TypeId Gets the current instance of this attribute. (Inherited from RegistrationAttribute.)

Top

Methods

  Name Description
Public method Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public method Register Registers this attribute. (Overrides RegistrationAttribute.Register(RegistrationAttribute.RegistrationContext).)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Unregister Removes the key from the registry. (Overrides RegistrationAttribute.Unregister(RegistrationAttribute.RegistrationContext).)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

Top

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.

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
}

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

Other Resources

Options Pages

User Settings and Options

Creating Options Pages By Using Managed Package Framework Classes

Registering Custom Options Pages

Persisting Settings