Ejemplo n.º 1
0
        public RazorEngineCompiledTemplate Compile(string content, Action <RazorEngineCompilationOptionsBuilder> builderAction = null)
        {
            RazorEngineCompilationOptionsBuilder compilationOptionsBuilder = new RazorEngineCompilationOptionsBuilder();

            compilationOptionsBuilder.Inherits(typeof(RazorEngineTemplateBase));

            builderAction?.Invoke(compilationOptionsBuilder);

            MemoryStream memoryStream = this.CreateAndCompileToStream(content, compilationOptionsBuilder.Options);

            return(new RazorEngineCompiledTemplate(memoryStream));
        }
Ejemplo n.º 2
0
        public RazorEngineCompiledTemplate <T> Compile <T>(string content, Action <RazorEngineCompilationOptionsBuilder> builderAction = null) where T : RazorEngineTemplateBase
        {
            RazorEngineCompilationOptionsBuilder compilationOptionsBuilder = new RazorEngineCompilationOptionsBuilder();

            compilationOptionsBuilder.AddAssemblyReference(typeof(T).Assembly);
            compilationOptionsBuilder.Inherits(typeof(T));

            builderAction?.Invoke(compilationOptionsBuilder);

            MemoryStream memoryStream = this.CreateAndCompileToStream(content, compilationOptionsBuilder.Options);

            return(new RazorEngineCompiledTemplate <T>(memoryStream));
        }