/// <summary> /// 编译模板 /// </summary> /// <param name="content"></param> /// <param name="builderAction"></param> /// <returns></returns> public IViewEngineTemplate Compile(string content, Action <IViewEngineOptionsBuilder> builderAction = null) { IViewEngineOptionsBuilder compilationOptionsBuilder = new ViewEngineOptionsBuilder(); compilationOptionsBuilder.Inherits(typeof(ViewEngineModel)); builderAction?.Invoke(compilationOptionsBuilder); var memoryStream = CreateAndCompileToStream(content, compilationOptionsBuilder.Options); return(new ViewEngineTemplate(memoryStream)); }
/// <summary> /// 编译模板 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="content"></param> /// <param name="builderAction"></param> /// <returns></returns> public IViewEngineTemplate <T> Compile <T>(string content, Action <IViewEngineOptionsBuilder> builderAction = null) where T : IViewEngineModel { IViewEngineOptionsBuilder compilationOptionsBuilder = new ViewEngineOptionsBuilder(); compilationOptionsBuilder.AddAssemblyReference(typeof(T).Assembly); compilationOptionsBuilder.Inherits(typeof(T)); builderAction?.Invoke(compilationOptionsBuilder); var memoryStream = CreateAndCompileToStream(content, compilationOptionsBuilder.Options); return(new ViewEngineTemplate <T>(memoryStream)); }