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); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { StreamEntry StreamEntry = (StreamEntry)value; if (StreamEntry != null) { StreamEntry.Save().WriteTo(writer); } else { writer.WriteNull(); } }