Exemple #1
0
        public void Write(string value)
        {
            using (var memoryOwner = _bufferPool.Rent(_encoding.Value.GetMaxByteCount(value.Length)))
            {
                int length = _encoding.Value.GetBytes(value.AsSpan(), memoryOwner.Memory.Span);
                Varint.SetUInt32((uint)length, _bufferWriter);

                _bufferWriter.Write(memoryOwner.Memory.Span.Slice(0, length));
            }
        }
Exemple #2
0
 public void Write(ReadOnlySpan <byte> value)
 {
     Varint.SetUInt32((uint)value.Length, _bufferWriter);
     _bufferWriter.Write(value);
 }