ProvideProfileAttribute 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将此属性应用于用于实现 VSPackage 的 Visual Studio 设置支持的独立对象。
public ref class ProvideProfileAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttributepublic 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 RegistrationAttributePublic NotInheritable Class ProvideProfileAttribute
Inherits RegistrationAttribute- 继承
- 属性
示例
在下面的示例中, 的 ProvideProfileAttribute 两个实例应用于 VSPackage 实现,以定义这两个类,为类 MyPackage实现的 VSPackage 提供 Visual Studio 设置支持。
- 由于名为“DesignerOptionsPage”的页面的实现派生自 DialogPage,因此它可以支持 Visual Studio 设置和 “工具选项” 页,并且注册为同时提供: - “工具选项”页的实现,该页通过 实例 ProvideOptionPageAttribute注册。 有关支持 “工具选项” 页的详细信息,请参阅 ProvideOptionPageAttribute。 
- 支持持久保存 “工具选项” 页的状态的实现,该状态由构造函数的最后一个参数 - ProvideProfileAttribute指示。
 
- 名为“PersistedDesignerState”的类注册为仅提供 Visual Studio 设置支持,通过实现 IProfileManager保存和检索名为“MyPackage”的 VSPackage 的剩余状态信息。 
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  
}  
注解
对调用者的说明
              ProvideProfileAttribute当存在实现 VSPackage 的 Visual Studio 设置功能的类时,将 特性应用于实现 VSPackage 的类,从而允许它保存和检索 VSPackage 状态信息。
注意
实现 的 IProfileManager类还必须实现 IComponent,这可以通过从 Component派生类来完成。
特性上下文
| 适用于 | 通过实现 或 DialogPage 接口的类使用 Visual Studio 设置机制的 IProfileManager VSPackage。 | 
| 可重复 | 是 | 
| 必需属性 | DefaultRegistryRootAttribute 请注意,如果实现 Visual Studio 设置的类还提供“工具选项”页,ProvideOptionPageAttribute则还需要。 | 
| 无效的特性 | 无 | 
实现者须知
此属性仅用于注册目的,不会影响运行时行为。
              ProvideProfileAttribute 注册实现 IProfileManager 或 DialogPage 的类,以提供通过 Visual Studio 设置机制保留部分或全部 VSPackage 状态的支持。 实现类保留的状态信息称为 Visual Studio 设置类别,其定义项在注册表中称为自定义设置点。
当用户选择“工具”菜单上的“导入/导出设置”命令以保存 Visual Studio 设置时,由 注册ProvideProfileAttribute的类将由 IDE 实例化并用于保存设置。
因此:
- Visual Studio 设置支持应在其自己的对象上实现,而不是在 VSPackage 本身上实现。 
- 实现 Visual Studio 设置的类可能仅支持自定义设置点中定义的一个 Visual Studio 设置类别。 
但是,只要定义了多个自定义设置点,单个 VSPackage 就可能支持多个 Visual Studio 设置类别:
- 每个 Visual Studio 设置类别在单独的类中实现。 
- 实现 Visual Studio 设置的每个类都通过其自己的 实例 - ProvideProfileAttribute注册为支持 VSPackage。- 注意 - 这不同于基于 COM 的实现,其中实现 Visual Studio 设置的类可能支持多个自定义设置点。 
的 ProvideProfileAttribute实例:
- 使用从 Type 实现 Visual Studio 设置的 类的 获取的 GUID 唯一标识自定义设置点的 Visual Studio 设置类别。 
- 设置 Visual Studio 设置类别的名称,包括注册表项中使用的规范的非本地化名称及其本地化名称资源。 
- 指示支持类实现的 - ProvideProfileAttributeVisual Studio 设置是否支持 “工具选项” 页 (有关支持 “工具选项” 页的详细信息,请参阅 选项页) 。
有关创建和应用 实例的详细信息 ProvideProfileAttribute,请参阅以下示例 和 ProvideProfileAttribute。
构造函数
| ProvideProfileAttribute(Type, String, String, Int16, Int16, Boolean) | 初始化 ProvideProfileAttribute 的新实例。 | 
属性
| AlternateParent | 获取或设置配置文件中不同类别的名称。 | 
| CategoryName | 获取 Visual Studio 设置类别的规范非局部化名称。 | 
| CategoryResourceID | 获取 Visual Studio 设置类别的名称资源 ID。 | 
| DescriptionResourceID | 获取配置文件的此页的说明的本地化资源 ID。 | 
| GroupName | 获取此组的非局部化名称。 | 
| GroupResourceID | 获取或设置此页所属组的本地化资源 ID。 | 
| IsToolsOptionPage | 获取这是否也是“工具选项”页。 | 
| MigrationType | 设置要对此类别执行的迁移操作。 | 
| ObjectName | 获取配置文件中此页的规范非本地化名称。 | 
| ObjectNameResourceID | 获取配置文件中此页名称的本地化资源 ID。 | 
| ObjectType | 获取页面的类型。 | 
| ResourcePackageGuid | 获取或设置提供资源字符串的包的 GUID。 | 
| TypeId | 重写 TypeID 属性,以便让 RegistrationAttribute 派生类与 System.ComponentModel.TypeDescriptor.GetAttributes 一起使用 (...) 。仅当派生自此属性的属性需要对可应用于类的实例使用更好的控件时,它才必须重写此属性。(继承自 RegistrationAttribute) | 
方法
| GetPackageRegKeyPath(Guid) | 获取相对于 VSPackage 的应用程序) 注册表根目录 (注册表路径。(继承自 RegistrationAttribute) | 
| Register(RegistrationAttribute+RegistrationContext) | 注册此属性。 | 
| Unregister(RegistrationAttribute+RegistrationContext) | 从注册表中删除项。 |