public T ReadObject <T>(Stream stream)
 {
     using (Logger.BeginScope($"{nameof(ReadObject)}"))
     {
         using (var reader = new BinaryReader(stream, Encoding, LeaveOpen))
         {
             var length = reader.ReadInt32();
             var bytes  = reader.ReadBytes(length);
             Logger.LogDebug($"Read stream.\r\nBytes length : {length}\r\nBytes : {BytesLogString(bytes)}");
             var converter = new ObjectBinaryConverter <T>();
             return(converter.FromByteArray(bytes));
         }
     }
 }
 public void WriteObject <T>(Stream stream, T obj)
 {
     using (Logger.BeginScope($"{nameof(WriteObject)}"))
     {
         using (var writer = new BinaryWriter(stream, Encoding, LeaveOpen))
         {
             var converter = new ObjectBinaryConverter <T>();
             var bytes     = converter.ToByteArray(obj);
             var length    = bytes.Length;
             writer.Write(length);
             writer.Write(bytes);
             Logger.LogDebug($"Write stream.\r\nBytes length : {length}\r\nBytes : {BytesLogString(bytes)}");
         }
     }
 }