CodeEntryPointMethod Classe

Definizione

Rappresenta il metodo del punto di ingresso di un eseguibile.

public ref 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
[<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
Ereditarietà
Attributi

Esempio

In questo esempio viene illustrato l'uso di per CodeEntryPointMethod indicare il metodo in cui avviare l'esecuzione del programma.

// 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

Commenti

È CodeEntryPointMethod un oggetto CodeMemberMethod che rappresenta il metodo del punto di ingresso di un eseguibile.

Costruttori

Nome Descrizione
CodeEntryPointMethod()

Inizializza una nuova istanza della classe CodeEntryPointMethod.

Proprietà

Nome Descrizione
Attributes

Ottiene o imposta gli attributi del membro.

(Ereditato da CodeTypeMember)
Comments

Ottiene la raccolta di commenti per il membro del tipo.

(Ereditato da CodeTypeMember)
CustomAttributes

Ottiene o imposta gli attributi personalizzati del membro.

(Ereditato da CodeTypeMember)
EndDirectives

Ottiene le direttive end per il membro.

(Ereditato da CodeTypeMember)
ImplementationTypes

Ottiene i tipi di dati delle interfacce implementate da questo metodo, a meno che non si tratti di un'implementazione di metodo privato, indicata dalla PrivateImplementationType proprietà .

(Ereditato da CodeMemberMethod)
LinePragma

Ottiene o imposta la riga in cui si verifica l'istruzione membro del tipo.

(Ereditato da CodeTypeMember)
Name

Ottiene o imposta il nome del membro.

(Ereditato da CodeTypeMember)
Parameters

Ottiene le dichiarazioni di parametro per il metodo .

(Ereditato da CodeMemberMethod)
PrivateImplementationType

Ottiene o imposta il tipo di dati dell'interfaccia di questo metodo, se privato, implementa un metodo di , se presente.

(Ereditato da CodeMemberMethod)
ReturnType

Ottiene o imposta il tipo di dati del valore restituito del metodo .

(Ereditato da CodeMemberMethod)
ReturnTypeCustomAttributes

Ottiene gli attributi personalizzati del tipo restituito del metodo .

(Ereditato da CodeMemberMethod)
StartDirectives

Ottiene le direttive start per il membro.

(Ereditato da CodeTypeMember)
Statements

Ottiene le istruzioni all'interno del metodo .

(Ereditato da CodeMemberMethod)
TypeParameters

Ottiene i parametri di tipo per il metodo generico corrente.

(Ereditato da CodeMemberMethod)
UserData

Ottiene i dati definibili dall'utente per l'oggetto corrente.

(Ereditato da CodeObject)

Metodi

Nome Descrizione
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Eventi

Nome Descrizione
PopulateImplementationTypes

Evento che verrà generato la prima volta che si accede alla ImplementationTypes raccolta.

(Ereditato da CodeMemberMethod)
PopulateParameters

Evento che verrà generato la prima volta che si accede alla Parameters raccolta.

(Ereditato da CodeMemberMethod)
PopulateStatements

Evento che verrà generato la prima volta che si accede alla Statements raccolta.

(Ereditato da CodeMemberMethod)

Si applica a

Vedi anche