private object ReadChar(BinaryContext context)
 {
     try
         {
             var bytes = context.ReadBytes(2);
             Array.Reverse(bytes);
             return BitConverter.ToChar(bytes, 0);
         }
         catch (Exception exception)
         {
             throw new InvalidOperationException("Cannot read char from given context", exception);
         }
 }
 public List<byte[]> Split(long sizeOffset, long sizeLength, BinaryContext context)
 {
     var result = new List<byte[]>();
     while (!context.EndOfContextReached())
     {
         var sizeValue = context.PeekBytes(sizeOffset, sizeLength);
         var size = ConvertSize(sizeValue);
         if (context.CanReadBytes(size))
         {
             result.Add(context.ReadBytes(size));
         }
         else throw new EndOfStreamException("Cannot read next block of size " + size);
     }
     return result;
 }
        public List<byte[]> Split(long sizeValue, BinaryContext context)
        {
            var result = new List<byte[]>();
            while (!context.EndOfContextReached())
            {

                if (context.CanReadBytes(sizeValue))
                {
                    result.Add(context.ReadBytes(sizeValue));
                }
                else throw new EndOfStreamException("Cannot read next block of size " + sizeValue);
            }
            return result;
        }
 private object ReadString(BinaryContext context)
 {
     try
         {
             var str = "";
             var bytes = context.ReadBytes(2);
             var ch = BitConverter.ToChar(bytes, 0);
             while (ch != '\0')
             {
                 str = str + ch;
                 bytes = context.ReadBytes(2);
                 ch = BitConverter.ToChar(bytes, 0);
             }
             return str;
         }
         catch (Exception exception)
         {
             throw new InvalidOperationException("Cannot read string from given context", exception);
         }
 }