Sdílet prostřednictvím


RazorTemplateEngine.GenerateCode Metoda

Definice

Přetížení

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

Analyzuje šablonu určenou textbufferem, vygeneruje pro ni kód a vrátí vytvořený kód.

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

Analyzuje obsah určený objektem inputStream a vrátí vygenerovaný kód.

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

Parametry

input
TextReader
className
String
rootNamespace
String
sourceFileName
String

Návraty

Platí pro

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

Analyzuje šablonu určenou textbufferem, vygeneruje pro ni kód a vrátí vytvořený kód.

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

Parametry

input
ITextBuffer

Vstupní text, který se má analyzovat.

className
String

Název vygenerované třídy, přepsání toho, co je zadáno v Host. Výchozí hodnotu (definovanou v hostiteli) lze použít zadáním hodnoty null pro tento argument.

rootNamespace
String

Obor názvů, ve kterém se vygenerovaná třída bude nacházet, přepisuje vše, co je zadáno v hostu. Výchozí hodnotu (definovanou v hostiteli) lze použít zadáním hodnoty null pro tento argument.

sourceFileName
String

Název souboru, který se má použít v pragma řádku, obvykle původní soubor Razor, přepisující vše, co je zadáno v hostiteli. Výchozí hodnotu (definovanou v hostiteli) lze použít zadáním hodnoty null pro tento argument.

cancelToken
Nullable<CancellationToken>

Token použitý ke zrušení analyzátoru.

Návraty

Výsledný strom analýzy A vygenerovaný kód.

Poznámky

Poskytnutý token zrušení se dá použít ke zrušení analýzy. Mějte však na paměti, že k analýze dochází ve vlákně volajících _synchronně_. Tento parametr je k dispozici, takže pokud je volající ve vlákně na pozadí s CancellationToken, může ho předat do analyzátoru.

Parametry className, rootNamespace a sourceFileName jsou volitelné a přepisují výchozí hodnotu určenou hostitelem. Například WebPageRazorHost v System.Web.WebPages.Razor konfiguruje název třídy, kořenový obor názvů a název zdrojového souboru na základě virtuální cesty kompilované stránky. Integrovaná třída RazorEngineHost však používá konstantní výchozí hodnoty, takže volající bude pravděpodobně chtít je pomocí těchto parametrů změnit.

Platí pro

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

Parametry

input
TextReader
className
String
rootNamespace
String
sourceFileName
String

Návraty

Platí pro

GenerateCode(Stream, String, String, String)

Analyzuje obsah určený objektem inputStream a vrátí vygenerovaný kód.

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

Parametry

inputStream
Stream

A Stream , který představuje obsah, který se má analyzovat.

className
String

Název vygenerované třídy. Když nullje výchozí hodnota DefaultClassName (Host.DefaultClassName).

rootNamespace
String

Obor názvů, ve kterém se vygenerovaná třída bude nacházet. Když nullje výchozí hodnota DefaultNamespace (Host.DefaultNamespace).

sourceFileName
String

Název souboru, který se má použít v pragma řádku, obvykle původní soubor Razor.

Návraty

A GeneratorResults , který představuje výsledky analýzy obsahu.

Poznámky

Toto přetížení vypočítá kontrolní součet obsahu inputStream před generováním kódu. Kontrolní součet se používá k vytvoření čáry direktivy #pragma checksum pragma vyžadované pro ladění.

Platí pro

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

Parametry

input
ITextBuffer
className
String
rootNamespace
String
sourceFileName
String

Návraty

Platí pro

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

Parametry

input
TextReader

Návraty

Platí pro

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

Parametry

input
ITextBuffer

Návraty

Platí pro

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

Parametry

input
TextReader

Návraty

Platí pro

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

Parametry

input
ITextBuffer

Návraty

Platí pro