共用方式為


ProvideCodeGeneratorAttribute 類別

將此屬性套用至 Visual Studio 擴充中提供自訂工具的套件類別。

此 API 不符合 CLS 標準。 

繼承階層架構

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.TextTemplating.VSHost.ProvideCodeGeneratorAttribute

命名空間:  Microsoft.VisualStudio.TextTemplating.VSHost
組件:  Microsoft.VisualStudio.TextTemplating.VSHost.10.0 (在 Microsoft.VisualStudio.TextTemplating.VSHost.10.0.dll 中)

語法

'宣告
<CLSCompliantAttribute(False)> _
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := False)> _
Public NotInheritable Class ProvideCodeGeneratorAttribute _
    Inherits RegistrationAttribute
[CLSCompliantAttribute(false)]
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class ProvideCodeGeneratorAttribute : RegistrationAttribute
[CLSCompliantAttribute(false)]
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = false)]
public ref class ProvideCodeGeneratorAttribute sealed : public RegistrationAttribute
[<Sealed>]
[<CLSCompliantAttribute(false)>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = false)>]
type ProvideCodeGeneratorAttribute =  
    class
        inherit RegistrationAttribute
    end
public final class ProvideCodeGeneratorAttribute extends RegistrationAttribute

ProvideCodeGeneratorAttribute 型別會公開下列成員。

建構函式

  名稱 說明
公用方法 ProvideCodeGeneratorAttribute 將此屬性套用至提供程式碼產生器的套件之套件類別。

回頁首

屬性

  名稱 說明
公用屬性 Description 這個產生器的人類看得懂的描述
公用屬性 GeneratesDesignTimeSource 如果為 true,這個程式碼產生器會提供設計階段原始程式碼
公用屬性 Name 這個產生器的名稱。若要將這個產生器套用至 [方案總管] 中的檔案,請將其 [自訂工具] 屬性設定為這個名稱。
公用屬性 ProjectSystem 這個程式碼產生器註冊至的專案系統。
公用屬性 RegisterCodeBase 如果為 true,則會使用程式碼基底 (即特定組件檔案位置) 註冊產生器。如果為 false,則組件會在 GAC 中。
公用屬性 Type 型別,實作程式碼產生器
公用屬性 TypeId (繼承自 RegistrationAttribute)。

回頁首

方法

  名稱 說明
公用方法 Equals 基礎架構。傳回數值,表示這個執行個體是否等於指定的物件。 (繼承自 Attribute)。
受保護的方法 Finalize 允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。 (繼承自 Object)。
公用方法 GetHashCode 傳回這個執行個體的雜湊程式碼。 (繼承自 Attribute)。
受保護的方法 GetPackageRegKeyPath (繼承自 RegistrationAttribute)。
公用方法 GetType 取得目前執行個體的 Type。 (繼承自 Object)。
公用方法 IsDefaultAttribute 在衍生類別中覆寫時,表示這個執行個體的值是否為衍生類別的預設值。 (繼承自 Attribute)。
公用方法 Match 在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。 (繼承自 Attribute)。
受保護的方法 MemberwiseClone 建立目前 Object 的淺層複本 (Shallow Copy)。 (繼承自 Object)。
公用方法 Register 呼叫以定義註冊這個程式碼產生器所必須進行的變更。通常應將機碼加入至登錄。 (覆寫 RegistrationAttribute.Register(RegistrationAttribute.RegistrationContext)。)
公用方法 ToString 傳回表示目前物件的字串。 (繼承自 Object)。
公用方法 Unregister 呼叫以定義移除這個程式碼產生器之註冊所必須進行的變更。通常應將 Register() 所加入的機碼刪除。 (覆寫 RegistrationAttribute.Unregister(RegistrationAttribute.RegistrationContext)。)

回頁首

欄位

  名稱 說明
公用欄位靜態成員 AspNetProjectGuid ASP.Net Project System 封裝的 Guid
公用欄位靜態成員 CSharpProjectGuid C# 專案系統封裝的 Guid
公用欄位靜態成員 VisualBasicProjectGuid Visual Basic Project System 封裝的 Guid

回頁首

明確介面實作

  名稱 說明
明確介面實作私用方法 _Attribute.GetIDsOfNames 將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。 (繼承自 Attribute)。
明確介面實作私用方法 _Attribute.GetTypeInfo 擷取物件的型別資訊,可以用來取得介面的型別資訊。 (繼承自 Attribute)。
明確介面實作私用方法 _Attribute.GetTypeInfoCount 擷取物件提供的型別資訊介面數目 (0 或 1)。 (繼承自 Attribute)。
明確介面實作私用方法 _Attribute.Invoke 提供物件所公開的屬性和方法的存取權。 (繼承自 Attribute)。

回頁首

備註

這個屬性會將您的 Visual Studio 擴充功能註冊為自訂工具。 當使用者安裝具有這個屬性的擴充後,就可以使用 [方案總管] 中的 [執行自訂工具] 命令,透過該擴充來產生檔案。

這個屬性會自動執行Registering Single File Generators中所述的註冊工作。

將屬性套用至套建類別 (而不是產生器類別)。

請參閱ProvideCodeGeneratorExtensionAttribute

範例

[ProvideCodeGenerator(typeof(MyGenerator), "MyCustomTool", "My custom tool", true, ProjectSystem = ProvideCodeGeneratorAttribute.CSharpProjectGuid)]
internal sealed partial class MyPackage : Microsoft.VisualStudio.Shell
.Package
{ ... }
internal class MyGenerator : Microsoft.VisualStudio.Shell.Interop.IVsSingleFileGenerator
{ ... }

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

Microsoft.VisualStudio.TextTemplating.VSHost 命名空間