public static T LoadFromJson <T>(ReadOnlySpan <byte> buffer, ModelObject owner, ErrorCollector collector) where T : ModelObject { var reader = new Utf8JsonReader(buffer); reader.Read(); var context = new DeserializationContext(collector); var result = SerializationMap <T> .DeserializeFromJson(owner, ref reader, context); context.Notify(); return(result); }
public override void DeserializeFromJson(TOwner owner, ref Utf8JsonReader reader, DeserializationContext context) { if (reader.TokenType == JsonTokenType.Null) { return; } var instance = getter(owner); if (instance == null) { setter(owner, SerializationMap <TPropertyType> .DeserializeFromJson(owner, ref reader, context)); return; } base.DeserializeFromJson(owner, ref reader, context); }
public static T LoadFromJson <T>(byte[] buffer, ModelObject owner, ErrorCollector collector, int bufferLength = -1) where T : ModelObject { if (bufferLength == -1) { bufferLength = buffer.Length; } var reader = new Utf8JsonReader(new ReadOnlySequence <byte>(buffer, 0, bufferLength)); reader.Read(); var context = new DeserializationContext(collector); var result = SerializationMap <T> .DeserializeFromJson(owner, ref reader, context); context.Notify(); return(result); }
public override void DeserializeFromJson(TOwner owner, ref Utf8JsonReader reader, DeserializationContext context) { var list = getter(owner); list.Clear(); if (reader.ReadStartArray()) { while (reader.TokenType != JsonTokenType.EndArray) { var elem = SerializationMap <TElement> .DeserializeFromJson(owner, ref reader, context); if (elem != null) { list.Add(elem); } reader.Read(); } } }
public override T ReadFromJson(ref Utf8JsonReader reader, DeserializationContext context) => SerializationMap <T> .DeserializeFromJson(null, ref reader, context);