다음을 통해 공유


ProvideProfileAttribute Class

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

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

Syntax

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideProfileAttribute _
    Inherits RegistrationAttribute

Dim instance As ProvideProfileAttribute
[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
public final class ProvideProfileAttribute extends RegistrationAttribute

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.

참고

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.

    참고

    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 Tools 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
}

Inheritance Hierarchy

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

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

Concepts

Tools Options Pages

User Settings and Options

Creating Options Pages By Using Managed Package Framework Classes

Registering Custom Tools Options Pages

Persisting Settings

Reference

ProvideProfileAttribute Members

Microsoft.VisualStudio.Shell Namespace