相关疑难解决方法(0)

RazorEngine字符串布局和部分?

我像这样使用剃须刀引擎:

public class EmailService : IService
{
    private readonly ITemplateService templateService;

    public EmailService(ITemplateService templateService)
    {
        if (templateService == null)
        {
            throw new ArgumentNullException("templateService");
        }
        this.templateService = templateService;
    }

    public string GetEmailTemplate(string templateName)
    {
        if (templateName == null)
        {
            throw new ArgumentNullException("templateName");
        }
        Assembly assembly = Assembly.GetAssembly(typeof(EmailTemplate));
        Stream stream = assembly.GetManifestResourceStream(typeof(EmailTemplate), "{0}.cshtml".FormatWith(templateName));
        string template = stream.ReadFully();
        return template;
    }

    public string GetEmailBody(string templateName, object model = null)
    {
        if (templateName == null)
        {
            throw new ArgumentNullException("templateName");
        }
        string template = GetEmailTemplate(templateName); …
Run Code Online (Sandbox Code Playgroud)

c# embedded-resource razorengine

19
推荐指数
2
解决办法
1万
查看次数

如何缓存RazorEngine中的模板?

当您调用时RazorEngine.Razor.Compile(),编译的模板存储在哪里?

程序重启后是否可用?如果内存不足,会被丢弃吗?

RazorEngineASP.NET(MVC)项目中使用.应用程序重启后,预编译模板是否可用?

将它们存放在HttpContext.Cache?中会更有意义吗?如果我这样做,那么使用Compile绕过内部缓存的不同功能(除了)更有意义吗?有没有办法执行ITemplate并只是传递一个模型?

RazorEngine.Razor.Parse()任何缓存吗?或者每次都重新编译模板?

razor

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×1

embedded-resource ×1

razor ×1

razorengine ×1