예제 #1
0
 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);
     }
 }
예제 #2
0
        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);
        }