更新:2007 年 11 月
將類別 (Class) 識別成資料產生器。
命名空間: Microsoft.VisualStudio.TeamSystem.Data.DataGenerator
組件: Microsoft.VisualStudio.TeamSystem.Data (在 Microsoft.VisualStudio.TeamSystem.Data.dll 中)
語法
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False, Inherited := True)> _
<CLSCompliantAttribute(True)> _
Public NotInheritable Class GeneratorAttribute _
Inherits Attribute
Dim instance As GeneratorAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
[CLSCompliantAttribute(true)]
public sealed class GeneratorAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)]
[CLSCompliantAttribute(true)]
public ref class GeneratorAttribute sealed : public Attribute
public final class GeneratorAttribute extends Attribute
備註
GeneratorAttribute 可用來指定資料產生器所使用的設計工具。Generator 抽象基底類別具有 GeneratorAttribute 並指定 DefaultGeneratorDesigner。
在下列情況中,您應該使用 GeneratorAttribute:
- 您想要讓資料產生器使用自訂設計工具。
在下列情況中,您不應該使用 GeneratorAttribute:
資料產生器類別繼承自 Generator,而且您想要使用 DefaultGeneratorDesigner。
資料產生器類別繼承自已經使用 GeneratorAttribute 裝飾的另一個資料產生器類別,而且您滿意已經指定的設計工具。
範例
下列範例將說明如何使用 GeneratorAttribute 來裝飾類別。在此範例中,資料產生器會與名為 CustomDesignerType 的自訂設計工具產生關聯。
[Generator(typeof(CustomDesignerType))]
public class TestGenerator:Generator
{
}
<Generator(GetType(CustomDesignerType))> _
Public Class TestGenerator
Inherits Generator
End Class
繼承階層架構
System.Object
System.Attribute
Microsoft.VisualStudio.TeamSystem.Data.DataGenerator.GeneratorAttribute
執行緒安全
這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。
請參閱
參考
Microsoft.VisualStudio.TeamSystem.Data.DataGenerator 命名空間