本文整理匯總了VB.NET中System.CodeDom.Compiler.CodeDomProvider.CreateProvider方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET CodeDomProvider.CreateProvider方法的具體用法?VB.NET CodeDomProvider.CreateProvider怎麽用?VB.NET CodeDomProvider.CreateProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.CodeDom.Compiler.CodeDomProvider
的用法示例。
在下文中一共展示了CodeDomProvider.CreateProvider方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1:
Dim provider As CodeDomProvider
' Check for a provider corresponding to the input language.
If CodeDomProvider.IsDefinedLanguage(language) Then
provider = CodeDomProvider.CreateProvider(language)
' Display information about this language provider.
Console.WriteLine("Language provider: {0}", _
provider.ToString())
Console.WriteLine()
Console.WriteLine(" Default file extension: {0}", _
provider.FileExtension)
Console.WriteLine()
' Get the compiler settings for this language.
Dim langCompilerInfo As CompilerInfo = CodeDomProvider.GetCompilerInfo(language)
Dim langCompilerConfig As CompilerParameters = langCompilerInfo.CreateDefaultCompilerParameters()
Console.WriteLine(" Compiler options: {0}", _
langCompilerConfig.CompilerOptions)
Console.WriteLine(" Compiler warning level: {0}", _
langCompilerConfig.WarningLevel)
Else
' Tell the user that the language provider was not found.
Console.WriteLine("There is no provider configured for input language ""{0}"".", _
language)
End If
示例2: Program
' 導入命名空間
Imports System.CodeDom.Compiler
Imports Microsoft.CSharp
Imports System.Collections.Generic
Class Program
Shared Sub Main(ByVal args() As String)
DisplayCSharpCompilerInfo()
DisplayVBCompilerInfo()
Console.WriteLine("Press Enter key to exit.")
Console.ReadLine()
End Sub
Shared Sub DisplayCSharpCompilerInfo()
Dim provOptions As New Dictionary(Of String, String)
provOptions.Add("CompilerVersion", "v4")
' Get the provider for Microsoft.CSharp
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("CSharp", provOptions)
' Display the C# language provider information.
Console.WriteLine("CSharp provider is {0}", provider.ToString())
Console.WriteLine(" Provider hash code: {0}", provider.GetHashCode().ToString())
Console.WriteLine(" Default file extension: {0}", provider.FileExtension)
Console.WriteLine()
End Sub
Shared Sub DisplayVBCompilerInfo()
Dim provOptions As New Dictionary(Of String, String)
provOptions.Add("CompilerVersion", "v3.5")
' Get the provider for Microsoft.VisualBasic
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic", provOptions)
' Display the Visual Basic language provider information.
Console.WriteLine("Visual Basic provider is {0}", provider.ToString())
Console.WriteLine(" Provider hash code: {0}", provider.GetHashCode().ToString())
Console.WriteLine(" Default file extension: {0}", provider.FileExtension)
Console.WriteLine()
End Sub
End Class