C# 如何用RazorEngineService替换TemplateService?
我有如下所示的代码,我想用更新的RazorEngineService替换TemplateService。你能告诉我如何在我的代码中替换它吗 PS:我已经检查过了,但是当我试图重构代码以获得RazorEngineService时,我遇到了一些异常C# 如何用RazorEngineService替换TemplateService?,c#,razor,html-email,C#,Razor,Html Email,我有如下所示的代码,我想用更新的RazorEngineService替换TemplateService。你能告诉我如何在我的代码中替换它吗 PS:我已经检查过了,但是当我试图重构代码以获得RazorEngineService时,我遇到了一些异常 public class ReminderEmail { string templateFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmailTemplate
public class ReminderEmail
{
string templateFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmailTemplates");
string templateFilePath;
ReminderEmailModel model;
public ReminderEmail(ReminderEmailModel model)
{
this.model = model;
try
{
templateFilePath = Path.Combine(templateFolderPath, "ReminderEmail.cshtml");
}
catch (FileNotFoundException e)
{
//TODO: log file not found here
}
}
public string GetHtmlBody()
{
var templateService = new TemplateService();
var emailHtmlBody = templateService.Parse(File.ReadAllText(templateFilePath), model, null, null);
return emailHtmlBody;
}
}
见: