共用方式為


ProvideProfileAttribute 類別

定義

將此屬性套用至用來實作 VSPackage Visual Studio 設定支援的獨立物件。

public ref class ProvideProfileAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttribute
public 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 RegistrationAttribute
Public NotInheritable Class ProvideProfileAttribute
Inherits RegistrationAttribute
繼承
ProvideProfileAttribute
屬性

範例

在下列範例中,會將的 ProvideProfileAttribute 兩個實例套用至 VSPackage 實作,以定義兩個類別,以提供 類別所實作之 VSPackage 的 MyPackageVisual Studio 設定支援。

  1. 由於名為 “DesignerOptionsPage” 的頁面實作衍生自 DialogPage,因此它可以支援 Visual Studio 設定和 [工具選項 ] 頁面,並註冊為同時提供:

    • [ 工具選項 ] 頁面的實作,這個頁面會透過 實例 ProvideOptionPageAttribute註冊。 如您支援 [工具選項 ] 頁面的詳細資訊,請參閱 ProvideOptionPageAttribute

    • 支援保存 [工具選項 ] 頁面狀態的實作,其是由建構函式的最後一個自變數 ProvideProfileAttribute 表示。

  2. 名為 「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 的類別時,將 屬性套用至實作 VSPackage 的類別,該類別會實作 VSPackage 的設定功能,讓其能夠儲存和擷取 VSPackage 狀態資訊。

注意

實作 的 IProfileManager類別也必須實 IComponent作 ,這可以藉由從 Component衍生類別來完成。

屬性內容

適用於 透過實 IProfileManager 作 或 DialogPage 介面的類別,使用 Visual Studio 設定機制的 VSPackage。
可重複 Yes
必要的屬性 DefaultRegistryRootAttribute注意 如果實作 Visual Studio 設定的類別也提供 [工具選項] 頁面,ProvideOptionPageAttribute則也需要 。
無效屬性

實作者的注意事項

此屬性僅用於註冊用途,且不會影響運行時間行為。

ProvideProfileAttribute 透過 Visual Studio 設定機制,註冊實作 IProfileManagerDialogPage 作為保存部分或所有 VSPackage 狀態的支援。 實作類別所保存的狀態資訊稱為 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 實作 Visual Studio 設定之 類別的 取得的 GUID。

  • 設定 Visual Studio 設定類別的名稱,包括登錄專案及其當地語系化名稱資源中使用的標準、非當地語系化名稱。

  • 指出 Visual Studio 設定是否支援類別的 實 ProvideProfileAttribute 作支援 [工具選項 ] 頁面 (如需支援 [工具選項 ] 頁面的詳細資訊,請參閱 選項頁面) 。

如需建立和套用 實體 ProvideProfileAttribute的詳細資訊,請參閱下列範例和 ProvideProfileAttribute

建構函式

ProvideProfileAttribute(Type, String, String, Int16, Int16, Boolean)

初始化 ProvideProfileAttribute 的新實例。

屬性

AlternateParent

取得或設定配置檔中不同類別的名稱。

CategoryName

取得 Visual Studio 設定類別的正式非本機名稱。

CategoryResourceID

取得 Visual Studio 設定類別的名稱資源識別碼。

DescriptionResourceID

取得設定檔此頁面描述的當地語系化資源識別碼。

GroupName

取得這個群組的非本機名稱。

GroupResourceID

取得或設定此頁面所屬群組的當地語系化資源識別碼。

IsToolsOptionPage

取得這是否也是 [工具選項] 頁面。

MigrationType

設定要為此類別採取的移轉動作。

ObjectName

取得配置檔中此頁面的正式非本機名稱。

ObjectNameResourceID

取得設定檔中此頁面名稱的當地語系化資源識別碼。

ObjectType

取得頁面的類型。

ResourcePackageGuid

取得或設定提供資源字串之封裝的 GUID。

TypeId

覆寫 TypeID 屬性,讓 RegistrationAttribute 衍生類別搭配 System.ComponentModel.TypeDescriptor.GetAttributes (...) 。衍生自這個屬性的屬性只有在需要對可套用至類別的實例有更好的控制權時,才必須覆寫此屬性。

(繼承來源 RegistrationAttribute)

方法

GetPackageRegKeyPath(Guid)

取得相對於 VSPackage 之應用程式) 之登錄根目錄的登錄路徑 (。

(繼承來源 RegistrationAttribute)
Register(RegistrationAttribute+RegistrationContext)

註冊此屬性。

Unregister(RegistrationAttribute+RegistrationContext)

從登錄中移除機碼。

適用於