Partager via


ProvideOptionPageAttribute Class

Apply this attribute to independent objects to allow users to configure VSPackages through a custom Tools Options page.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)

Syntax

'Déclaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideOptionPageAttribute _
    Inherits ProvideOptionDialogPageAttribute
'Utilisation
Dim instance As ProvideOptionPageAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideOptionPageAttribute : ProvideOptionDialogPageAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideOptionPageAttribute sealed : public ProvideOptionDialogPageAttribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideOptionPageAttribute =  
    class
        inherit ProvideOptionDialogPageAttribute
    end
public final class ProvideOptionPageAttribute extends ProvideOptionDialogPageAttribute

Remarks

Notes for Implementers

Apply the ProvideOptionPageAttribute to classes implementing a VSPackage. This attribute enables to register that a specific independent object provides the VSPackage's users with configuration access through a custom Tools Options page.

Attribute Context

Applies to

VSPackages allow configuration through custom Tools Options pages implemented either through the Managed Package Framework's DialogPage or by using the Visual Studio SDK code.

Repeatable

Yes

Required attributes

DefaultRegistryRootAttribute

Invalid attributes

None

Notes for Callers

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

The ProvideOptionPageAttribute registers a given class implementing IProfileManager or DialogPage as providing a particular VSPackage support for persisting part or all of 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.

Notes

When a Managed Package Framework based custom Tools Options page is loaded, the IDE instantiates the object registered by ProvideOptionPageAttribute as implementing it. Managed Package Framework Tools Options page support should be implemented on its own object and not on the VSPackage itself.

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

Examples

In the example below, an instance of ProvideOptionPageAttribute is applied to a VSPackage implementation to register the class DesignerOptionsPage, which is derived from DialogPage, as providing the VSPackage with a Tools Options page.

Classes derived from DialogPage are provided with a default implementation of Visual Studio settings functionality, which can be overridden. The IDE makes use of this Visual Studio settings support if, as in the example, ProvideProfileAttribute is applied to the VSPackage implementation. For more information on Visual Studio settings support, see User Settings and Options.

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.ProvideOptionDialogPageAttribute
        Microsoft.VisualStudio.Shell.ProvideOptionPageAttribute

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

ProvideOptionPageAttribute Members

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