/// <summary> /// Compiles, caches and parses a template using RazorEngine. /// </summary> /// <param name="templateType">Type of the template.</param> /// <param name="anonymousType">Type of the anonymous object.</param> /// <param name="cachedEnabled">true to enabled caching; false otherwise</param> /// <returns></returns> public static string GetTemplate <T>(EmailTemplateType templateType, T anonymousType, bool cachedEnabled = true) { string templateName = templateType.ToString(); if (cachedEnabled == false) { ResetCache(); } // pre-compile, cache & parse the template return(Engine.Razor.RunCompile(templateName, null, anonymousType)); }
/// <summary> /// Get <paramref name="EmailTemplate"/> as per <paramref name="EmailTemplateType"/>. /// </summary> public EmailTemplate GetBy(EmailTemplateType emailTemplateType) { var root = XElement.Load("EmailTemplates.config"); var template = root.Elements("emailTemplate") .Where(x => x.Attribute("id").Value == emailTemplateType.ToString()) .SingleOrDefault(); if (template == null) { throw new ApplicationException($"{emailTemplateType} missing in EmailTemplates.config."); } return Convert(template); }
public static string get_email_template(Guid?applicationId, EmailTemplateType templateType, Dictionary <string, string> dic) { if (RaaiVanSettings.SAASBasedMultiTenancy) { applicationId = null; } Initialize(applicationId); if (dic == null) { dic = new Dictionary <string, string>(); } string retStr = Expressions.replace(Templates.get_value(applicationId, templateType.ToString()), ref dic, Expressions.Patterns.AutoTag); return(string.IsNullOrEmpty(retStr) && applicationId.HasValue ? get_email_template(null, templateType, dic) : retStr); }