Esempio n. 1
0
        /// <summary>
        /// 编译模板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="builderAction"></param>
        /// <returns></returns>
        public IViewEngineCompiledTemplate Compile(string content, Action <IViewEngineCompilationOptionsBuilder> builderAction = null)
        {
            IViewEngineCompilationOptionsBuilder compilationOptionsBuilder = new ViewEngineCompilationOptionsBuilder();

            compilationOptionsBuilder.Inherits(typeof(ViewEngineTemplate));

            builderAction?.Invoke(compilationOptionsBuilder);

            var memoryStream = CreateAndCompileToStream(content, compilationOptionsBuilder.Options);

            return(new ViewEngineCompiledTemplate(memoryStream));
        }
Esempio n. 2
0
        /// <summary>
        /// 编译模板
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="content"></param>
        /// <param name="builderAction"></param>
        /// <returns></returns>
        public IViewEngineCompiledTemplate <T> Compile <T>(string content, Action <IViewEngineCompilationOptionsBuilder> builderAction = null) where T : IViewEngineTemplate
        {
            IViewEngineCompilationOptionsBuilder compilationOptionsBuilder = new ViewEngineCompilationOptionsBuilder();

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

            builderAction?.Invoke(compilationOptionsBuilder);

            var memoryStream = CreateAndCompileToStream(content, compilationOptionsBuilder.Options);

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