本文整理匯總了VB.NET中System.Web.Compilation.BuildProvider類的典型用法代碼示例。如果您正苦於以下問題:VB.NET BuildProvider類的具體用法?VB.NET BuildProvider怎麽用?VB.NET BuildProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BuildProvider類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: SampleBuildProvider
' 導入命名空間
Imports System.Collections
Imports System.IO
Imports System.Text
Imports System.Web
Imports System.Web.Compilation
Imports System.CodeDom.Compiler
Imports System.CodeDom
Imports System.Security
Imports System.Security.Permissions
<PermissionSet(SecurityAction.Demand, Unrestricted := true)> _
Public Class SampleBuildProvider
Inherits BuildProvider
Protected _compilerType As CompilerType = Nothing
Public Sub New()
_compilerType = GetDefaultCompilerType()
End Sub
' Return the internal CompilerType member
' defined in this implementation.
Public Overrides ReadOnly Property CodeCompilerType() As CompilerType
Get
CodeCompilerType = _compilerType
End Get
End Property
' Define the build provider implementation of the GenerateCode method.
Public Overrides Sub GenerateCode(ByVal assemBuilder As AssemblyBuilder)
' Generate a code compile unit, and add it to
' the assembly builder.
Dim tw As TextWriter = assemBuilder.CreateCodeFile(Me)
If Not tw Is Nothing Then
Try
' Generate the code compile unit from the virtual path.
Dim compileUnit As CodeCompileUnit = _
SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath)
' Generate the source for the code compile unit,
' and write it to a file specified by the assembly builder.
Dim provider As CodeDomProvider = assemBuilder.CodeDomProvider
provider.GenerateCodeFromCompileUnit(compileUnit, tw, Nothing)
Finally
tw.Close()
End Try
End If
End Sub
Public Overrides Function GetGeneratedType(ByVal results As CompilerResults) As System.Type
Dim typeName As String = SampleClassGenerator.TypeName
Return results.CompiledAssembly.GetType(typeName)
End Function
End Class