Example #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject Token = JObject.Load(reader);

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

                switch (Type)
                {
                case 2:
                    Entry = new ChatStreamEntry();
                    break;

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

                Entry.Load(Token);

                return(Entry);
            }
            else
            {
                Logging.Info(this.GetType(), "ReadJson() - JsonObject doesn't contains 'type' key.");
            }

            return(existingValue);
        }
Example #2
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();
            }
        }