CodeTypeDeclaration クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeTypeDeclaration Inherits CodeTypeMember
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeTypeDeclaration : CodeTypeMember
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class CodeTypeDeclaration : public CodeTypeMember

CodeTypeDeclaration を使用して、クラス、構造体、インターフェイス、または列挙体を宣言するコードを表すことができます。CodeTypeDeclaration を使用して、別の型の中に入れ子になった型を宣言できます。
BaseTypes プロパティは、宣言される型の 1 つ以上の基本型を指定します。Members プロパティは、型のメンバを格納します。これには、メソッド、フィールド、プロパティ、コメント、および他の型があります。TypeAttributes プロパティは、型宣言の TypeAttributes 値を示します。これはその型のカテゴリを示します。IsClass、IsStruct、IsEnum、および IsInterface の各メソッドは、それぞれ、その型がクラス型、構造体型、列挙体型、またはインターフェイス型かどうかを示します。
![]() |
---|
プログラミング言語によっては、参照型またはクラスの宣言しかサポートされないこともあります。言語固有の CodeDOM コード ジェネレータがインターフェイス、列挙体、または値型の宣言をサポートしているかどうかを調べるには、Supports メソッドを呼び出して該当する GeneratorSupport フラグを調べます。DeclareInterfaces はインターフェイスのサポートを示し、DeclareEnums は列挙体のサポートを示し、DeclareValueTypes は構造体などの値型のサポートを示します。 |
1 つの宣言内に完結するクラスまたは構造体の実装を作成することも、複数の宣言にわたって実装することもできます。IsPartial プロパティは、型宣言が完全か、部分的かを示します。部分的な型宣言がサポートされないコード ジェネレータもあるので、PartialTypes フラグを指定して Supports メソッドを呼び出し、このサポートをテストします。

CodeTypeDeclaration を使用して型を宣言する例を次に示します。
' Creates a new type declaration. Dim newType As New CodeTypeDeclaration("TestType") ' name parameter indicates the name of the type. ' Sets the member attributes for the type to private. newType.Attributes = MemberAttributes.Private ' Sets a base class which the type inherits from. newType.BaseTypes.Add("BaseType") ' A Visual Basic code generator produces the following source code for the preceeding example code: ' Class TestType ' Inherits BaseType ' End Class
// Creates a new type declaration. CodeTypeDeclaration newType = new CodeTypeDeclaration( // name parameter indicates the name of the type. "TestType"); // Sets the member attributes for the type to private. newType.Attributes = MemberAttributes.Private; // Sets a base class which the type inherits from. newType.BaseTypes.Add( "BaseType" ); // A C# code generator produces the following source code for the preceeding example code: // class TestType : BaseType // { // }
// Creates a new type declaration. // name parameter indicates the name of the type. CodeTypeDeclaration^ newType = gcnew CodeTypeDeclaration( "TestType" ); // Sets the member attributes for the type to private. newType->Attributes = MemberAttributes::Private; // Sets a base class which the type inherits from. newType->BaseTypes->Add( "BaseType" ); // A C# code generator produces the following source code for the preceeding example code: // class TestType : BaseType // { // }
// Creates a new type declaration. CodeTypeDeclaration newType = new CodeTypeDeclaration( // name parameter indicates the name of the type. "TestType"); // Sets the member attributes for the type to private. newType.set_Attributes(MemberAttributes.Private); // Sets a base class which the type inherits from. newType.get_BaseTypes().Add("BaseType"); // A VJ# code generator produces the following source code for the // preceeding example code: // class TestType extends BaseType // { // }

System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeTypeDeclaration
System.CodeDom.CodeTypeDelegate


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeTypeDeclaration クラスのページへのリンク