protected static int GetContentLength(
            IBinaryReadStream reader,
            int lengthLength,
            int offset)
        {
            switch (lengthLength)
            {
            case 1:
                return(reader.GetUInt8(offset));

            case 2:
                return(reader.GetUInt16(offset));

            case 4:
                return((int)reader.GetUInt32(offset));

            default:
                throw new NotImplementedException();
            }
        }
        public static bool TryGet(
            IBinaryReadStream reader,
            RecordType expectedHeader,
            out long contentLength,
            long lengthLength)
        {
            if (reader.Remaining < Constants.HeaderLength + lengthLength)
            {
                contentLength = -1;
                return(false);
            }
            var header = reader.GetInt32();

            if (expectedHeader.TypeInt != header)
            {
                contentLength = -1;
                return(false);
            }
            switch (lengthLength)
            {
            case 1:
                contentLength = reader.GetUInt8(offset: Constants.HeaderLength);
                break;

            case 2:
                contentLength = reader.GetUInt16(offset: Constants.HeaderLength);
                break;

            case 4:
                contentLength = reader.GetUInt32(offset: Constants.HeaderLength);
                break;

            default:
                throw new NotImplementedException();
            }
            return(true);
        }