public void WriteField(ref Writer writer, SerializerSession session, uint fieldIdDelta, Type expectedType, T[] value) { if (ReferenceCodec.TryWriteReferenceField(ref writer, session, fieldIdDelta, expectedType, value)) { return; } writer.WriteFieldHeader(session, fieldIdDelta, expectedType, value.GetType(), WireType.TagDelimited); Int32Codec.WriteField(ref writer, session, 0, typeof(int), value.Length); var first = true; foreach (var element in value) { this.fieldCodec.WriteField(ref writer, session, first ? 1U : 0, typeof(T), element); first = false; } writer.WriteEndObject(); }
void IFieldCodec <T[]> .WriteField <TBufferWriter>(ref Writer <TBufferWriter> writer, uint fieldIdDelta, Type expectedType, T[] value) { if (ReferenceCodec.TryWriteReferenceField(ref writer, fieldIdDelta, expectedType, value)) { return; } writer.WriteFieldHeader(fieldIdDelta, expectedType, value.GetType(), WireType.TagDelimited); Int32Codec.WriteField(ref writer, 0, typeof(int), value.Length); var first = true; foreach (var element in value) { this.fieldCodec.WriteField(ref writer, first ? 1U : 0, typeof(T), element); first = false; } writer.WriteEndObject(); }
public void WriteField <TBufferWriter>(ref Writer <TBufferWriter> writer, uint fieldIdDelta, Type expectedType, Memory <T> value) where TBufferWriter : IBufferWriter <byte> { if (ReferenceCodec.TryWriteReferenceField(ref writer, fieldIdDelta, expectedType, value)) { return; } writer.WriteFieldHeader(fieldIdDelta, expectedType, value.GetType(), WireType.TagDelimited); Int32Codec.WriteField(ref writer, 0, typeof(int), value.Length); var first = true; foreach (var element in value.Span) { _fieldCodec.WriteField(ref writer, first ? 1U : 0, typeof(T), element); first = false; } writer.WriteEndObject(); }