コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }