CodeDOM - Code Document Object Model




コード グラフ コンテナ
ソース コード要素の種類代表的な CodeDOM 要素
コンパイル可能なソース コードのグラフ。CodeCompileUnit
コンパイル可能なリテラル コードのセクション。CodeSnippetCompileUnit
名前空間宣言要素
ソース コード要素の種類代表的な CodeDOM 要素
名前空間宣言CodeNamespace
名前空間宣言のコレクション。CodeNamespaceCollection
名前空間のインポート。CodeNamespaceImport
名前空間インポートのコレクション。CodeNamespaceImportCollection
型宣言要素代表的な CodeDOM 要素
ソース コード要素の種類
クラス、構造体、または列挙体の型宣言。CodeTypeDeclaration
型宣言のコレクション。CodeTypeDeclarationCollection
型参照要素代表的な CodeDOM 要素
ソース コード要素の種類
型への参照。 CodeTypeReference
型への参照のコレクション。 CodeTypeReferenceCollection
型メンバ要素
ソース コード要素の種類代表的な CodeDOM 要素
型のメンバを表す抽象基本クラス。CodeTypeMember
型のメンバのコレクション表現。CodeTypeMemberCollection
クラス メソッド宣言。CodeMemberMethod
クラス フィールド宣言。 CodeMemberField
クラス プロパティ宣言。CodeMemberProperty
型のコンストラクタ。 CodeConstructor
型の静的コンストラクタ。CodeTypeConstructor
プログラムのエントリ ポイント表現。CodeEntryPoint
CodeTypeMember で使用される識別子の付いた属性表現。MemberAttributes
メンバ属性
ソース コード要素の種類 代表的な CodeDOM 要素
CodeTypeMember で使用されるメンバ修飾子の付いた属性表現。MemberAttributes
カスタム属性宣言。 CodeAttributeDeclaration
カスタム属性宣言のコレクション。 CodeAttributeDeclarationCollection
パラメータ宣言。 CodeParameterDeclarationExpression
パラメータ宣言のコレクション。 CodeParameterDeclarationExpressionCollection
カスタム属性の引数。 CodeAttributeArgument
カスタム属性のコレクションの引数。CodeAttributeArgumentCollection
フィールド方向修飾子
方向式。 CodeDirectionExpression
引数の方向表現。FieldDirection
コード ステートメント
ソース コード要素の種類 代表的な CodeDOM 要素
ステートメントの抽象基本クラス。 CodeStatement
コード ステートメントのコレクション。CodeStatementCollection
コード ステートメントとして処理できるコード式。CodeExpressionStatement
変数宣言ステートメント。CodeVariableDeclarationStatement
代入演算
値を代入するステートメント。 CodeAssignStatement
二項演算
二項演算子を表す式。二項演算子は、左オペランドと右オペランドと呼ばれる 2 つのオペランドを使用する演算子です。 CodeBinaryOperatorExpression
二項演算子の型表現。 CodeBinaryOperatorType
コメント
コメント。CodeComment
コメント ステートメント。 CodeCommentStatement
コメント ステートメントのコレクション。 CodeCommentStatementCollection
デリゲートおよびイベント
クラス イベント宣言。 CodeMemberEvent
デリゲート宣言。 CodeTypeDelegate
デリゲートを作成する式。 CodeDelegateCreateExpression
デリゲートを呼び出す式。 CodeDelegateInvokeExpression
デリゲートをイベントに結び付けるステートメント。CodeAttachEventStatement
デリゲートをイベントから削除するステートメント。CodeRemoveEventStatement
エラー処理
throw 例外ステートメント。 CodeThrowExceptionStatement
try...catch...finally ブロック。CodeTryCatchFinallyStatement
catch clause ブロック。 CodeCatchClause
catch clause ブロックのコレクション。 CodeCatchClauseCollection
フロー制御ステートメント
if ステートメント。CodeConditionStatement
for ループ ステートメント。CodeIterationStatement
goto ステートメント。 CodeGotoStatement
戻り値ステートメント。 CodeMethodReturnStatement
ラベル付きステートメント。CodeLabeledStatement
コード式
ソース コード要素の種類 代表的な CodeDOM 要素
式の抽象基本クラス。 CodeExpression
コード式のコレクション。 CodeExpressionCollection
オブジェクトまたは式をデータ型にキャストする式。 CodeCastExpression
プリミティブ値式。CodePrimitiveExpression
typeof 式。CodeTypeOfExpression
配列インデクサ。 CodeArrayIndexerExpression
引数への参照。CodeArgumentReferenceExpression
変数への参照。 CodeVariableReferenceExpression
型を参照する式。 CodeTypeReferenceExpression
プロパティ セットの値引数を表す式。 CodePropertySetValueReferenceExpression
オブジェクト作成
オブジェクトを作成する式。たとえば、new 演算子。 CodeObjectCreateExpression
配列を作成する式。 CodeArrayCreateExpression
メソッドの呼び出し
メソッドを呼び出す式。 CodeMethodInvokeExpression
メンバ参照
型インデクサ。 CodeIndexerExpression
基本クラスへの参照。 CodeBaseReferenceExpression
フィールドへの参照。 CodeFieldReferenceExpression
メソッドへの参照。 CodeMethodReferenceExpression
プロパティへの参照。 CodePropertyReferenceExpression
イベントへの参照。 CodeEventReferenceExpression
現在のオブジェクトへの参照。 CodeThisReferenceExpression
リテラル コード片
ソース コード要素の種類 代表的な CodeDOM 要素
コンパイル可能なリテラル コードの単位。 CodeSnippetCompileUnit
クラス メンバを表すリテラル コード要素。 CodeSnippetTypeMember
リテラル コード ステートメント。 CodeSnippetStatement
式を表すリテラル コード要素。 CodeSnippetExpression
その他
ソース コード要素の種類 代表的な CodeDOM 要素
CodeDOM オブジェクトの抽象基本クラス。 CodeObject
ファイル名と行番号を使用する位置表現。 CodeLinePragma



Derived from CodeStatement


Class Description
CodeAssignStatement Represents a simple assignment statement.
CodeAssignStatement^ as1 
    = gcnew CodeAssignStatement(
    
gcnew CodeVariableReferenceExpression("i" ),
gcnew CodePrimitiveExpression( 100 ) );
i=100;
CodeAttachEventStatement Represents a statement that attaches an event-handler delegate to an event.
CodeCommentStatement Represents a statement consisting of a single comment.
CodeConditionStatement Represents a conditional branch statement, typically represented as an if statement.
CodeExpressionStatement Represents a statement that consists of a single expression.
CodeGotoStatement Represents a goto statement.
CodeIterationStatement Represents a for statement, or a loop through a block of statements, using a test expression as a condition for continuing to loop.
CodeLabeledStatement Represents a labeled statement or a stand-alone label.
CodeMethodReturnStatement Represents a return value statement.
CodeRemoveEventStatement Represents a statement that removes an event handler.
CodeSnippetStatement Represents a statement using a literal code fragment.
CodeThrowExceptionStatement Represents a statement that throws an exception.
CodeTryCatchFinallyStatement Represents a try block with any number of catch clauses and, optionally, a finally block.
CodeVariableDeclarationStatement Represents a variable declaration.

Derived from CodeExpression

Class Description
CodeArgumentReferenceExpression Represents a reference to the value of an argument passed to a method.
CodeArrayCreateExpression Represents an expression that creates an array.
CodeArrayIndexerExpression Represents a reference to an index of an array.
CodeBaseReferenceExpression Represents a reference to the base class.
CodeBinaryOperatorExpression Represents an expression that consists of a binary operation between two expressions.
CodeCastExpression Represents an expression cast to a data type or interface.
CodeDefaultValueExpression Represents a reference to a default value.
CodeDelegateCreateExpression Represents an expression that creates a delegate.
CodeDelegateInvokeExpression Represents an expression that raises an event.
CodeDirectionExpression Represents an expression used as a method invoke parameter along with a reference direction indicator.
CodeEventReferenceExpression Represents a reference to an event.
CodeFieldReferenceExpression Represents a reference to a field.
CodeIndexerExpression Represents a reference to an indexer property of an object.
CodeMethodInvokeExpression Represents an expression that invokes a method.
CodeMethodReferenceExpression Represents a reference to a method.
CodeMethodReferenceExpression^ methodRef1 
    
= gcnew CodeMethodReferenceExpression(
gcnew CodeThisReferenceExpression,"func" ); array<CodeParameterDeclarationExpression^>^temp1; CodeMethodInvokeExpression^ invoke1 = gcnew CodeMethodInvokeExpression( methodRef1,temp1 );
this.func();
CodeObjectCreateExpression Represents an expression that creates a new instance of a type.
array<CodeExpression^>^temp0 
= gcnew array<CodeExpression^>(0); CodeObjectCreateExpression^ objectCreate1 = gcnew CodeObjectCreateExpression(
"System.DateTime", temp0 );
new System.DateTime();
CodeParameterDeclarationExpression Represents a parameter declaration for a method, property, or constructor.
CodeMemberMethod^ method1 = gcnew CodeMemberMethod(); method1->Name = "ReturnString";
    method1->ReturnType = gcnew CodeTypeReference("System.String"); method1->Parameters->Add(
    gcnew CodeParameterDeclarationExpression("System.String", "text")
    ); method1->Statements->Add( gcnew CodeMethodReturnStatement( gcnew CodeArgumentReferenceExpression("text")
    ) );

private string ReturnString(string text) { return text;
}

CodePrimitiveExpression Represents a primitive data type value.
CodePropertyReferenceExpression Represents a reference to the value of a property.
CodePropertySetValueReferenceExpression Represents the value argument of a property set method call within a property set method.
CodeSnippetExpression Represents a literal expression.
CodeThisReferenceExpression Represents a reference to the current local class instance.
CodeTypeOfExpression Represents a typeof expression, an expression that returns a Type for a specified type name.
CodeTypeReferenceExpression Represents a reference to a data type.
CodeVariableReferenceExpression Represents a reference to a local variable.


Hello World

static CodeCompileUnit^ HelloWorld()
{
   CodeCompileUnit^ CompileUnit = gcnew CodeCompileUnit;
   CodeNamespace^ Samples = gcnew CodeNamespace( "Samples" );
   CompileUnit->Namespaces->Add( Samples );
   Samples->Imports->Add( gcnew CodeNamespaceImport( "System" ) );
   CodeTypeDeclaration^ Class1 = gcnew CodeTypeDeclaration( "Class1" );
   Samples->Types->Add( Class1 );
   CodeEntryPointMethod^ Start = gcnew CodeEntryPointMethod;
   array<CodeExpression^>^temp = {gcnew CodePrimitiveExpression( "Hello World!" )};
   CodeMethodInvokeExpression^ cs1 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp );
   Start->Statements->Add( gcnew CodeExpressionStatement( cs1 ) );
   Class1->Members->Add( Start );
   return CompileUnit;
}