Esempio n. 1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            StreamEntry StreamEntry = (StreamEntry)value;

            if (StreamEntry != null)
            {
                StreamEntry.Save().WriteTo(writer);
            }
            else
            {
                writer.WriteNull();
            }
        }
Esempio n. 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject Token = JObject.Load(reader);

            int Type;

            if (JsonHelper.GetJsonNumber(Token, "type", out Type))
            {
                StreamEntry Entry;

                switch (Type)
                {
                case 1:
                    Entry = new DonateStreamEntry();
                    break;

                case 2:
                    Entry = new ChatStreamEntry();
                    break;

                case 3:
                    Entry = new JoinRequestStreamEntry();
                    break;

                case 4:
                    Entry = new EventStreamEntry();
                    break;

                case 16:
                    Entry = new GiftStreamEntry();
                    break;

                default:
                    Entry = new StreamEntry();
                    break;
                }

                Entry.Load(Token);

                return(Entry);
            }

            Logging.Info(this.GetType(), "ReadJson() - JsonObject doesn't contains 'type' key.");

            return(existingValue);
        }