public static string RenderTemplate([NotNull] this string template, [NotNull] object model) { if (template == null) { throw new ArgumentNullException(nameof(template)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } using (var writer = new StringWriter()) { GetCompiledTemplate(template, model.GetType())(writer, model); return(writer.ToString()); } }
/// <summary> /// Gets the message body. /// </summary> /// <param name="data">The notification body.</param> /// <returns>The string message body.</returns> public string GetMessageBody(Dictionary <string, object> data) { return(SendAllProperties ? JsonSerializer.Serialize(data, JsonDefaults.Options) : GetCompiledTemplate()(data)); }