ProvideProfileAttribute 类

将此特性应用于用于的独立对象实现 VSPackage 中 Visual Studio 设置的支持。

继承层次结构

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

命名空间:  Microsoft.VisualStudio.Shell
程序集:  Microsoft.VisualStudio.Shell.11.0(在 Microsoft.VisualStudio.Shell.11.0.dll 中)

语法

声明
<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

ProvideProfileAttribute 类型公开以下成员。

构造函数

  名称 说明
公共方法 ProvideProfileAttribute 初始化 ProvideProfileAttribute 的新实例。

页首

属性

  名称 说明
公共属性 AlternateParent 获取或设置不同的类别的名称将在配置文件中。
公共属性 CategoryName 获取 Visual Studio 设置类别的规范非本地化名称。
公共属性 CategoryResourceID 获取 Visual Studio 设置类别的名称资源 ID。
公共属性 DescriptionResourceID 获取该配置文件的以下页面声明的本地化的资源 ID。
公共属性 GroupName 获取此组的非本地化名称。
公共属性 GroupResourceID 获取或设置此页属于某个组的本地化的资源 ID。
公共属性 IsToolsOptionPage 获取是否也是 工具选项 页。
公共属性 MigrationType 设置迁移事件用于此类别的时间。
公共属性 ObjectName 获取此页的规范非本地化名称将在配置文件中。
公共属性 ObjectNameResourceID 获取此页的名称的本地化资源 ID。该配置文件的。
公共属性 ObjectType 获取页的类型。
公共属性 ResourcePackageGuid 获取或设置提供资源字符串的包的 GUID。
公共属性 TypeId 获取此属性的当前实例。 (继承自 RegistrationAttribute。)

页首

方法

  名称 说明
公共方法 Equals 基础结构。返回一个值,该值指示此实例是否与指定的对象相等。 (继承自 Attribute。)
公共方法 GetHashCode 返回此实例的哈希代码。 (继承自 Attribute。)
公共方法 GetType 获取当前实例的 Type。 (继承自 Object。)
公共方法 IsDefaultAttribute 当在派生类中重写时,指示此实例的值是否是派生类的默认值。 (继承自 Attribute。)
公共方法 Match 当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute。)
公共方法 Register 注册此属性。 (重写 RegistrationAttribute.Register(RegistrationAttribute.RegistrationContext)。)
公共方法 ToString 返回表示当前对象的字符串。 (继承自 Object。)
公共方法 Unregister 从注册表中移除项。 (重写 RegistrationAttribute.Unregister(RegistrationAttribute.RegistrationContext)。)

页首

显式接口实现

  名称 说明
显式接口实现私有方法 _Attribute.GetIDsOfNames 将一组名称映射为对应的一组调度标识符。 (继承自 Attribute。)
显式接口实现私有方法 _Attribute.GetTypeInfo 检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 (继承自 Attribute。)
显式接口实现私有方法 _Attribute.GetTypeInfoCount 检索对象提供的类型信息接口的数量(0 或 1)。 (继承自 Attribute。)
显式接口实现私有方法 _Attribute.Invoke 提供对某一对象公开的属性和方法的访问。 (继承自 Attribute。)

页首

备注

调用方的说明

ProvideProfileAttribute 特性应用于实现 VSPackage 的类,在具有实现 Visual Studio VSPackage 的功能,允许它保存和检索 VSPackage 状态信息的类时。

备注

类实现 IProfileManager,必须还实现 IComponent,可以由派生类来完成从 Component

属性上下文

适用对象

使用 Visual Studio 设置结构的 Vspackage 通过实现 IProfileManagerDialogPage 接口的类。

可重复

必需的特性

还需要 DefaultRegistryRootAttribute,请注意,如果实现 Visual Studio 设置的类还提供 工具选项 页, ProvideOptionPageAttribute

无效的特性

实现者说明

此属性用于注册目的仅使用,并且不会影响运行时行为。

ProvideProfileAttribute 注册类实现 IProfileManager 的或 DialogPage 为了提供用于保留的部分或全部 VSPackage 的状态支持通过 Visual Studio 设置结构。 状态信息由实现的类仍然存在引用 Visual Studio 设置类别,因此,它在注册表中定义的项称为自定义下落点。

当用户在 工具 菜单的 导入/导出设置 命令保存 Visual Studio 设置时, ProvideProfileAttribute 注册类由 IDE 实例化和用于保存这些设置。

这样:

  • Visual Studio 设置支持应本身是实现的对象而不是 VSPackage。

  • 实现 Visual Studio 设置的类可以仅支持如自定义定义的类别下落点的一 Visual Studio 设置。

但是,单个 VSPackage 中支持多 Visual Studio 设置类别,在中定义的多个自定义下落点,只要:

  • 每 Visual Studio 设置类别在单独的类中实现。

  • 实现 Visual Studio 设置的每个类注册为支持 VSPackage 由 ProvideProfileAttribute自己的实例。

    备注

    这与实现 Visual Studio 设置的类支持多个自定义下落点的基于 COM 的实现方式不同。

ProvideProfileAttribute实例:

  • 唯一标识与实现Visual Studio 设置的类的 Type 获取的 GUID 的自定义下落点的 Visual Studio  设置类别。

  • 设置 Visual Studio 设置类别的名称,用于注册表项的自己的规范,非本地化名称及其本地化名称资源。

  • 指示支持 ProvideProfileAttribute 类的实现的 Visual Studio 设置是否支持 工具选项 页 (有关支持 工具选项 页的更多信息,请参见 选项卡页)。

有关创建并应用 ProvideProfileAttribute实例的更多信息,请参见该下面的示例和 ProvideProfileAttribute

示例

在下面的示例中, ProvideProfileAttribute 两个实例是否应用于 VSPackage 实现定义两个类,提供 Visual Studio 设置为 VSPackage 支持实现由类 MyPackage。

  1. 由于名为 “DesignerOptionsPage”页的实现从派生 DialogPage,它可以支持 Visual Studio 设置和 工具选项 页和注册为提供两种:

    • 工具选项 页的实现,将实例 ProvideOptionPageAttribute注册。 有关支持 工具选项 页的更多信息,请参见 ProvideOptionPageAttribute

    • 支持持久 工具选项 状态的实现调用,由最终参数表示于 ProvideProfileAttribute 构造函数。

  2. 名为 “PersistedDesignerState”类注册,提供 Visual Studio 设置支持,保存和检索实现名为 “Mypackage::close()” VSPackage 中剩余的状态信息 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
}

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参见

参考

Microsoft.VisualStudio.Shell 命名空间

其他资源

选项卡页

用户设置和选项

创建使用托管包框架类的选项卡页

注册自定义选项卡页

保留的设置