共用方式為


RazorTemplateEngine.GenerateCode 方法

定義

多載

GenerateCode(TextReader, String, String, String, Nullable<CancellationToken>)
GenerateCode(ITextBuffer, String, String, String, Nullable<CancellationToken>)

剖析 TextBuffer 指定的範本、為其產生程式碼,並傳回建構的程式碼。

GenerateCode(TextReader, String, String, String)
GenerateCode(Stream, String, String, String)

剖析 所 inputStream 指定的內容,並傳回產生的程式碼。

GenerateCode(ITextBuffer, String, String, String)
GenerateCode(TextReader, Nullable<CancellationToken>)
GenerateCode(ITextBuffer, Nullable<CancellationToken>)
GenerateCode(TextReader)
GenerateCode(ITextBuffer)

GenerateCode(TextReader, String, String, String, Nullable<CancellationToken>)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(System::IO::TextReader ^ input, System::String ^ className, System::String ^ rootNamespace, System::String ^ sourceFileName, Nullable<System::Threading::CancellationToken> cancelToken);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (System.IO.TextReader input, string className, string rootNamespace, string sourceFileName, System.Threading.CancellationToken? cancelToken);
member this.GenerateCode : System.IO.TextReader * string * string * string * Nullable<System.Threading.CancellationToken> -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As TextReader, className As String, rootNamespace As String, sourceFileName As String, cancelToken As Nullable(Of CancellationToken)) As GeneratorResults

參數

input
TextReader
className
String
rootNamespace
String
sourceFileName
String

傳回

適用於

GenerateCode(ITextBuffer, String, String, String, Nullable<CancellationToken>)

剖析 TextBuffer 指定的範本、為其產生程式碼,並傳回建構的程式碼。

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(Microsoft::AspNetCore::Razor::Text::ITextBuffer ^ input, System::String ^ className, System::String ^ rootNamespace, System::String ^ sourceFileName, Nullable<System::Threading::CancellationToken> cancelToken);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (Microsoft.AspNetCore.Razor.Text.ITextBuffer input, string className, string rootNamespace, string sourceFileName, System.Threading.CancellationToken? cancelToken);
member this.GenerateCode : Microsoft.AspNetCore.Razor.Text.ITextBuffer * string * string * string * Nullable<System.Threading.CancellationToken> -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As ITextBuffer, className As String, rootNamespace As String, sourceFileName As String, cancelToken As Nullable(Of CancellationToken)) As GeneratorResults

參數

input
ITextBuffer

要剖析的輸入文字。

className
String

產生的類別名稱,覆寫 Host 中指定的任何專案。 您可以在 Host) 中定義的預設值 (,方法是為此引數提供 null。

rootNamespace
String

產生類別所在的命名空間,覆寫 Host 中指定的任何專案。 您可以在 Host) 中定義的預設值 (,方法是為此引數提供 null。

sourceFileName
String

在 line pragmas 中使用的檔案名,通常是原始的 Razor 檔案,覆寫 Host 中指定的任何專案。 您可以在 Host) 中定義的預設值 (,方法是為此引數提供 null。

cancelToken
Nullable<CancellationToken>

用來取消剖析器的權杖。

傳回

產生的剖析樹狀結構 AND 產生的程式碼。

備註

提供的取消權杖可用來取消剖析。 不過,請注意,剖析會在呼叫端執行緒上發生 _synchronously_。 提供此參數,因此,如果呼叫端位於具有 CancellationToken 的背景執行緒中,則可以將它沿著傳遞至剖析器。

className、rootNamespace 和 sourceFileName 參數是選擇性的,並覆寫 Host 所指定的預設值。 例如,System.Web.WebPages.Razor 中的 WebPageRazorHost 會根據所編譯頁面的虛擬路徑,設定類別名稱、根命名空間和來原始檔案名。 不過,內建的 RazorEngineHost 類別會使用常數預設值,因此呼叫端可能會想要使用這些參數來變更它們。

適用於

GenerateCode(TextReader, String, String, String)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(System::IO::TextReader ^ input, System::String ^ className, System::String ^ rootNamespace, System::String ^ sourceFileName);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (System.IO.TextReader input, string className, string rootNamespace, string sourceFileName);
member this.GenerateCode : System.IO.TextReader * string * string * string -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As TextReader, className As String, rootNamespace As String, sourceFileName As String) As GeneratorResults

參數

input
TextReader
className
String
rootNamespace
String
sourceFileName
String

傳回

適用於

GenerateCode(Stream, String, String, String)

剖析 所 inputStream 指定的內容,並傳回產生的程式碼。

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(System::IO::Stream ^ inputStream, System::String ^ className, System::String ^ rootNamespace, System::String ^ sourceFileName);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (System.IO.Stream inputStream, string className, string rootNamespace, string sourceFileName);
member this.GenerateCode : System.IO.Stream * string * string * string -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (inputStream As Stream, className As String, rootNamespace As String, sourceFileName As String) As GeneratorResults

參數

inputStream
Stream

Stream 表示要剖析的內容。

className
String

產生的類別名稱。 當 為 時 null ,預設為 DefaultClassName (Host.DefaultClassName) 。

rootNamespace
String

已產生類別中會存在命名空間。 當 為 時 null ,預設為 DefaultNamespace (Host.DefaultNamespace) 。

sourceFileName
String

要用於行 pragmas 的檔案名,通常是原始的 Razor 檔案。

傳回

GeneratorResults 表示剖析內容的結果。

備註

此多載會計算程式碼產生之前的內容 inputStream 總和檢查碼。 總和檢查碼用於產生 #pragma checksum 偵錯所需的行 pragma。

適用於

GenerateCode(ITextBuffer, String, String, String)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(Microsoft::AspNetCore::Razor::Text::ITextBuffer ^ input, System::String ^ className, System::String ^ rootNamespace, System::String ^ sourceFileName);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (Microsoft.AspNetCore.Razor.Text.ITextBuffer input, string className, string rootNamespace, string sourceFileName);
member this.GenerateCode : Microsoft.AspNetCore.Razor.Text.ITextBuffer * string * string * string -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As ITextBuffer, className As String, rootNamespace As String, sourceFileName As String) As GeneratorResults

參數

input
ITextBuffer
className
String
rootNamespace
String
sourceFileName
String

傳回

適用於

GenerateCode(TextReader, Nullable<CancellationToken>)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(System::IO::TextReader ^ input, Nullable<System::Threading::CancellationToken> cancelToken);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (System.IO.TextReader input, System.Threading.CancellationToken? cancelToken);
member this.GenerateCode : System.IO.TextReader * Nullable<System.Threading.CancellationToken> -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As TextReader, cancelToken As Nullable(Of CancellationToken)) As GeneratorResults

參數

input
TextReader

傳回

適用於

GenerateCode(ITextBuffer, Nullable<CancellationToken>)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(Microsoft::AspNetCore::Razor::Text::ITextBuffer ^ input, Nullable<System::Threading::CancellationToken> cancelToken);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (Microsoft.AspNetCore.Razor.Text.ITextBuffer input, System.Threading.CancellationToken? cancelToken);
member this.GenerateCode : Microsoft.AspNetCore.Razor.Text.ITextBuffer * Nullable<System.Threading.CancellationToken> -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As ITextBuffer, cancelToken As Nullable(Of CancellationToken)) As GeneratorResults

參數

input
ITextBuffer

傳回

適用於

GenerateCode(TextReader)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(System::IO::TextReader ^ input);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (System.IO.TextReader input);
member this.GenerateCode : System.IO.TextReader -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As TextReader) As GeneratorResults

參數

input
TextReader

傳回

適用於

GenerateCode(ITextBuffer)

public:
 Microsoft::AspNetCore::Razor::CodeGenerators::GeneratorResults ^ GenerateCode(Microsoft::AspNetCore::Razor::Text::ITextBuffer ^ input);
public Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults GenerateCode (Microsoft.AspNetCore.Razor.Text.ITextBuffer input);
member this.GenerateCode : Microsoft.AspNetCore.Razor.Text.ITextBuffer -> Microsoft.AspNetCore.Razor.CodeGenerators.GeneratorResults
Public Function GenerateCode (input As ITextBuffer) As GeneratorResults

參數

input
ITextBuffer

傳回

適用於