CodeEntryPointMethod クラス

定義

実行可能ファイルのエントリ ポイント メソッドを表します。

public ref class CodeEntryPointMethod : System::CodeDom::CodeMemberMethod
public class CodeEntryPointMethod : System.CodeDom.CodeMemberMethod
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeEntryPointMethod : System.CodeDom.CodeMemberMethod
type CodeEntryPointMethod = class
    inherit CodeMemberMethod
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeEntryPointMethod = class
    inherit CodeMemberMethod
Public Class CodeEntryPointMethod
Inherits CodeMemberMethod
継承
属性

この例では、 を CodeEntryPointMethod 使用して、プログラムの実行を開始するメソッドを示します。

// Builds a Hello World Program Graph using System.CodeDom objects
static CodeCompileUnit^ BuildHelloWorldGraph()
{
   
   // Create a new CodeCompileUnit to contain the program graph
   CodeCompileUnit^ CompileUnit = gcnew CodeCompileUnit;
   
   // Declare a new namespace object and name it
   CodeNamespace^ Samples = gcnew CodeNamespace( "Samples" );
   
   // Add the namespace object to the compile unit
   CompileUnit->Namespaces->Add( Samples );
   
   // Add a new namespace import for the System namespace
   Samples->Imports->Add( gcnew CodeNamespaceImport( "System" ) );
   
   // Declare a new type object and name it
   CodeTypeDeclaration^ Class1 = gcnew CodeTypeDeclaration( "Class1" );
   
   // Add the new type to the namespace object's type collection
   Samples->Types->Add( Class1 );
   
   // Declare a new code entry point method
   CodeEntryPointMethod^ Start = gcnew CodeEntryPointMethod;
   
   // Create a new method invoke expression
   array<CodeExpression^>^temp = {gcnew CodePrimitiveExpression( "Hello World!" )};
   CodeMethodInvokeExpression^ cs1 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp );
   
   // Add the new method code statement
   Start->Statements->Add( gcnew CodeExpressionStatement( cs1 ) );
   
   // Add the code entry point method to the type's members collection
   Class1->Members->Add( Start );
   return CompileUnit;
// Builds a Hello World Program Graph using System.CodeDom objects
public static CodeCompileUnit BuildHelloWorldGraph()
{
    // Create a new CodeCompileUnit to contain the program graph
    CodeCompileUnit CompileUnit = new CodeCompileUnit();

    // Declare a new namespace object and name it
    CodeNamespace Samples = new CodeNamespace("Samples");
    // Add the namespace object to the compile unit
    CompileUnit.Namespaces.Add( Samples );

    // Add a new namespace import for the System namespace
    Samples.Imports.Add( new CodeNamespaceImport("System") );

    // Declare a new type object and name it
    CodeTypeDeclaration Class1 = new CodeTypeDeclaration("Class1");
    // Add the new type to the namespace object's type collection
    Samples.Types.Add(Class1);

    // Declare a new code entry point method
    CodeEntryPointMethod Start = new CodeEntryPointMethod();
    // Create a new method invoke expression
    CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression(
        // Call the System.Console.WriteLine method
        new CodeTypeReferenceExpression("System.Console"), "WriteLine",
        // Pass a primitive string parameter to the WriteLine method
        new CodePrimitiveExpression("Hello World!") );
    // Add the new method code statement
    Start.Statements.Add(new CodeExpressionStatement(cs1));

    // Add the code entry point method to the type's members collection
    Class1.Members.Add( Start );

    return CompileUnit;
' Builds a Hello World Program Graph using System.CodeDom objects
Public Shared Function BuildHelloWorldGraph() As CodeCompileUnit
   ' Create a new CodeCompileUnit to contain the program graph
   Dim CompileUnit As New CodeCompileUnit()
   
   ' Declare a new namespace object and name it
   Dim Samples As New CodeNamespace("Samples")
   ' Add the namespace object to the compile unit
   CompileUnit.Namespaces.Add(Samples)
   
   ' Add a new namespace import for the System namespace
   Samples.Imports.Add(New CodeNamespaceImport("System"))
   
   ' Declare a new type object and name it
   Dim Class1 As New CodeTypeDeclaration("Class1")
   ' Add the new type to the namespace object's type collection
   Samples.Types.Add(Class1)
   
   ' Declare a new code entry point method
   Dim Start As New CodeEntryPointMethod()
   ' Create a new method invoke expression
   Dim cs1 As New CodeMethodInvokeExpression(New CodeTypeReferenceExpression("System.Console"), "WriteLine", New CodePrimitiveExpression("Hello World!"))
   ' Call the System.Console.WriteLine method
   ' Pass a primitive string parameter to the WriteLine method
   ' Add the new method code statement
   Start.Statements.Add(New CodeExpressionStatement(cs1))
   
   ' Add the code entry point method to the type's members collection
   Class1.Members.Add(Start)
   
   Return CompileUnit

End Function 'BuildHelloWorldGraph

注釈

CodeEntryPointMethodは、CodeMemberMethod実行可能ファイルのエントリ ポイント メソッドを表す です。

コンストラクター

CodeEntryPointMethod()

CodeEntryPointMethod クラスの新しいインスタンスを初期化します。

プロパティ

Attributes

メンバーの属性を取得または設定します。

(継承元 CodeTypeMember)
Comments

型メンバーのコメント コレクションを取得します。

(継承元 CodeTypeMember)
CustomAttributes

メンバーのカスタム属性を取得または設定します。

(継承元 CodeTypeMember)
EndDirectives

メンバーの終了ディレクティブを取得します。

(継承元 CodeTypeMember)
ImplementationTypes

メソッドの実装が PrivateImplementationType プロパティで示されるプライベート メソッド実装である場合を除き、このメソッドによって実装されるインターフェイスのデータ型を取得します。

(継承元 CodeMemberMethod)
LinePragma

型メンバーのステートメントが発生する行を取得または設定します。

(継承元 CodeTypeMember)
Name

メンバーの名前を取得または設定します。

(継承元 CodeTypeMember)
Parameters

メソッドのパラメーター宣言を取得します。

(継承元 CodeMemberMethod)
PrivateImplementationType

このメソッドによってプライベート メソッドが実装されるインターフェイスがある場合に、そのインターフェイスのデータ型を取得または設定します。

(継承元 CodeMemberMethod)
ReturnType

メソッドの戻り値のデータ型を取得または設定します。

(継承元 CodeMemberMethod)
ReturnTypeCustomAttributes

メソッドの戻り値の型のカスタム属性を取得します。

(継承元 CodeMemberMethod)
StartDirectives

メンバーの開始ディレクティブを取得します。

(継承元 CodeTypeMember)
Statements

メソッド内で、ステートメントを取得します。

(継承元 CodeMemberMethod)
TypeParameters

現在のジェネリック メソッドの型パラメーターを取得します。

(継承元 CodeMemberMethod)
UserData

現在のオブジェクトのユーザー定義可能なデータを取得します。

(継承元 CodeObject)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

イベント

PopulateImplementationTypes

ImplementationTypes コレクションが最初にアクセスされたときに発生するイベント。

(継承元 CodeMemberMethod)
PopulateParameters

Parameters コレクションが最初にアクセスされたときに発生するイベント。

(継承元 CodeMemberMethod)
PopulateStatements

Statements コレクションが最初にアクセスされたときに発生するイベント。

(継承元 CodeMemberMethod)

適用対象

こちらもご覧ください