public static string GetMessageAsString(this NotifyEntry entry, HtmlEncoder htmlEncoder) { var stringBuilder = new StringBuilder(); using (var stringWriter = new StringWriter(stringBuilder)) { entry.Message.WriteTo(stringWriter, htmlEncoder); } return(stringBuilder.ToString()); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jo = JObject.Load(reader); NotifyType type; var notifyEntry = new NotifyEntry(); notifyEntry.Message = new HtmlString(jo.Value <string>("Message")); if (Enum.TryParse(jo.Value <string>("Type"), out type)) { notifyEntry.Type = type; } return(notifyEntry); }