private void WriteMetadata(BufferWriter bufferWriter) { var metadata = bufferWriter.MetadataManager.ToString(); if (metadata.HasValue()) { var bytes = this._Encoding.GetBytes(metadata); var lengthBytes = BitConverter.GetBytes(bytes.Length); this.stream.Write(lengthBytes, 0, lengthBytes.Length); this.stream.Write(bytes, 0, bytes.Length); } }
public void Write(object value) { var bufferWriter = new BufferWriter(_Encoding); bufferWriter.Write(value); WriteMetadata(bufferWriter); var bytes = new byte[bufferWriter.stream.Length]; bufferWriter.stream.Position = 0; bufferWriter.stream.Read(bytes, 0, bytes.Length); stream.Write(bytes, 0, bytes.Length); }