コード例 #1
0
        static BEncodedList DecodeList(ref ReadOnlySpan <byte> buffer, bool strictDecoding)
        {
            var list = new BEncodedList();

            while (buffer.Length > 0)
            {
                if (buffer[0] == 'e')
                {
                    buffer = buffer.Slice(1);
                    return(list);
                }
                list.Add(Decode(ref buffer, strictDecoding));
            }
            throw new BEncodingException("Invalid data found. Aborting");
        }
コード例 #2
0
        static BEncodedList DecodeList(Stream reader, bool strictDecoding)
        {
            var list = new BEncodedList();
            int read;

            while ((read = reader.ReadByte()) != -1)
            {
                if (read == 'e')
                {
                    return(list);
                }
                list.Add(Decode(reader, strictDecoding, read));
            }

            throw new BEncodingException("Invalid data found. Aborting");
        }
コード例 #3
0
        static BEncodedList DecodeList(RawReader reader)
        {
            var list = new BEncodedList();
            int read;

            while ((read = reader.ReadByte()) != -1 && read != 'e')
            {
                list.Add(Decode(reader, read));
            }

            if (read != 'e')                            // Remove the trailing 'e'
            {
                throw new BEncodingException("Invalid data found. Aborting");
            }

            return(list);
        }