C# Класс RazorEngine.Compilation.RazorCompiler

Provides compilation services for razor templates.
Показать файл Открыть проект

Открытые методы

Метод Описание
CompileTemplate ( string className, string template, Type modelType = null ) : CompilerResults

Compiles the string template into a ITemplate.

CreateTemplate ( string template, Type modelType = null ) : ITemplate

Creates a ITemplate from the specified string template.

GetCode ( string className, string template, Type modelType = null, string baseTypeName = null, string outputNamespace = null ) : string

Compiles the string cshtml template into a cs string

RazorCompiler ( ILanguageProvider provider, Type baseType = null, System.Web.Razor.Parser.MarkupParser parser = null ) : System

Initialises a new instance of RazorCompiler

Приватные методы

Метод Описание
AddNamespaceImports ( CodeNamespace generator ) : void

Adds any required namespace imports to the generated

AddReferences ( CompilerParameters parameters ) : void

Adds any required references to the compiler parameters.

BuildDynamicName ( Type type ) : string

Builds the full declarative name of the specified type with a dynamic type argument.

BuildName ( ILanguageProvider provider, Type type ) : string

Builds the full declarative name of the specified type.

GenerateCode ( CodeDomProvider codeDom, System.Web.Razor.Generator.RazorCodeGenerator codeGenerator, StringBuilder builder ) : void

Generates the required code using the specified compile unit.

GetBaseTypeDeclaration ( ILanguageProvider languageProvider, Type modelType, Type templateBaseType = null ) : string

Gets the base type declaration for the template.

GetBaseTypeReferencedAssemblies ( ) : IEnumerable

Gets the locations of assemblies referenced by a custom base template type.

GetCoreReferences ( ) : IEnumerable

Gets the locations of all core referenced assemblies.

IsAnonymousType ( Type type ) : bool

Determines if the specified type represents an anonymous type.

ParseTemplate ( string template, System.Web.Razor.Parser.RazorParser parser, System.Web.Razor.Parser.ParserVisitor visitor ) : void

Parses the specified template.

Описание методов

CompileTemplate() публичный Метод

Compiles the string template into a ITemplate.
public CompileTemplate ( string className, string template, Type modelType = null ) : CompilerResults
className string The name of the compiled class.
template string The template to compile.
modelType System.Type [Optional] The model type.
Результат System.CodeDom.Compiler.CompilerResults

CreateTemplate() публичный Метод

Creates a ITemplate from the specified string template.
public CreateTemplate ( string template, Type modelType = null ) : ITemplate
template string The string template to create a for.
modelType System.Type [Optional] The model type.
Результат ITemplate

GetCode() публичный Метод

Compiles the string cshtml template into a cs string
public GetCode ( string className, string template, Type modelType = null, string baseTypeName = null, string outputNamespace = null ) : string
className string The name of the compiled class.
template string The template to compile.
modelType System.Type [Optional] The model type.
baseTypeName string [Optional] Base type for the template. To be used if the model type is /// in an unreferenced assembly.
outputNamespace string
Результат string

RazorCompiler() публичный Метод

Initialises a new instance of RazorCompiler
public RazorCompiler ( ILanguageProvider provider, Type baseType = null, System.Web.Razor.Parser.MarkupParser parser = null ) : System
provider ILanguageProvider The language provider used to create language services.
baseType System.Type [Optional] The template base type.
parser System.Web.Razor.Parser.MarkupParser [Optional] The markup parser.
Результат System