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
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
Комментарии
A 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 |
Возвращает директивы start для члена. (Унаследовано от 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) |