コード例 #1
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;
        }
コード例 #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);
        }
コード例 #3
0
        private string SerializeNotifyEntry(NotifyEntry[] notifyEntries)
        {
            var settings = new JsonSerializerSettings();
            settings.Converters.Add(new NotifyEntryConverter());

            try
            {
                var protector = CreateTenantProtector();
                var signed = protector.Protect(JsonConvert.SerializeObject(notifyEntries, settings));
                return WebUtility.UrlEncode(signed);
            }
            catch
            {
                return null;
            }
        }