public static MemoryStream SaveToJson <T>(T obj) where T : ModelObject { var ms = new MemoryStream(); using (var writer = new Utf8JsonWriter(ms)) SerializationMap <T> .SerializeToJson(obj, writer); ms.Position = 0; return(ms); }
public override void SerializeToJson(TOwner owner, Utf8JsonWriter writer) { var list = getter(owner); writer.WriteStartArray(); foreach (var elem in list) { SerializationMap <TElement> .SerializeToJson(elem, writer); } writer.WriteEndArray(); }
public override void SerializeToJson(TOwner owner, Utf8JsonWriter writer) { var instance = getter(owner); if (instance == null) { writer.WriteNullValue(); } else if (instance.GetType() == typeof(TPropertyType)) { SerializationMap <TPropertyType> .SerializeToJson(instance, writer); } else { SerializationMap.GetSerializationMap(instance.GetType()).SerializeToJson(instance, writer); } }
public override void SerializeToJson(object target, Utf8JsonWriter writer) { SerializationMap <T> .SerializeToJson(target as T, writer); }
public override void WriteToJson(Utf8JsonWriter writer, T value) => SerializationMap <T> .SerializeToJson(value, writer);