本文整理匯總了VB.NET中System.CodeDom.CodeEntryPointMethod類的典型用法代碼示例。如果您正苦於以下問題:VB.NET CodeEntryPointMethod類的具體用法?VB.NET CodeEntryPointMethod怎麽用?VB.NET CodeEntryPointMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CodeEntryPointMethod類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: BuildHelloWorldGraph
' 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