CodeEntryPointMethod Klasse

Definition

Stellt die Einstiegspunktmethode einer ausführbaren Datei dar.

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
Vererbung
Attribute

Beispiele

In diesem Beispiel wird die Verwendung einer CodeEntryPointMethod Methode zum Starten der Programmausführung veranschaulicht.

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

Hinweise

A CodeEntryPointMethod ist eine CodeMemberMethod , die die Einstiegspunktmethode einer ausführbaren Datei darstellt.

Konstruktoren

Name Beschreibung
CodeEntryPointMethod()

Initialisiert eine neue Instanz der CodeEntryPointMethod-Klasse.

Eigenschaften

Name Beschreibung
Attributes

Ruft die Attribute des Elements ab oder legt diese fest.

(Geerbt von CodeTypeMember)
Comments

Ruft die Sammlung von Kommentaren für das Typelement ab.

(Geerbt von CodeTypeMember)
CustomAttributes

Dient zum Abrufen oder Festlegen der benutzerdefinierten Attribute des Elements.

(Geerbt von CodeTypeMember)
EndDirectives

Ruft die Enddirektiven für das Element ab.

(Geerbt von CodeTypeMember)
ImplementationTypes

Ruft die Datentypen der von dieser Methode implementierten Schnittstellen ab, es sei denn, es handelt sich um eine private Methodenimplementierung, die durch die PrivateImplementationType Eigenschaft angegeben wird.

(Geerbt von CodeMemberMethod)
LinePragma

Ruft die Zeile ab, in der die Element-Anweisung des Typs auftritt, oder legt sie fest.

(Geerbt von CodeTypeMember)
Name

Dient zum Abrufen oder Festlegen des Namens des Elements.

(Geerbt von CodeTypeMember)
Parameters

Ruft die Parameterdeklarationen für die Methode ab.

(Geerbt von CodeMemberMethod)
PrivateImplementationType

Dient zum Abrufen oder Festlegen des Datentyps der Schnittstelle, die diese Methode, falls privat, eine Methode von, falls vorhanden, implementiert.

(Geerbt von CodeMemberMethod)
ReturnType

Dient zum Abrufen oder Festlegen des Datentyps des Rückgabewerts der Methode.

(Geerbt von CodeMemberMethod)
ReturnTypeCustomAttributes

Ruft die benutzerdefinierten Attribute des Rückgabetyps der Methode ab.

(Geerbt von CodeMemberMethod)
StartDirectives

Ruft die Startdirektiven für das Mitglied ab.

(Geerbt von CodeTypeMember)
Statements

Ruft die Anweisungen innerhalb der Methode ab.

(Geerbt von CodeMemberMethod)
TypeParameters

Ruft die Typparameter für die aktuelle generische Methode ab.

(Geerbt von CodeMemberMethod)
UserData

Ruft die vom Benutzer definierbaren Daten für das aktuelle Objekt ab.

(Geerbt von CodeObject)

Methoden

Name Beschreibung
Equals(Object)

Bestimmt, ob das angegebene Objekt dem aktuellen Objekt entspricht.

(Geerbt von Object)
GetHashCode()

Dient als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft die Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie der aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Ereignisse

Name Beschreibung
PopulateImplementationTypes

Ein Ereignis, das beim ersten Zugriff auf die ImplementationTypes Auflistung ausgelöst wird.

(Geerbt von CodeMemberMethod)
PopulateParameters

Ein Ereignis, das beim ersten Zugriff auf die Parameters Auflistung ausgelöst wird.

(Geerbt von CodeMemberMethod)
PopulateStatements

Ein Ereignis, das beim ersten Zugriff auf die Statements Auflistung ausgelöst wird.

(Geerbt von CodeMemberMethod)

Gilt für:

Weitere Informationen