PeekByte() публичный Метод

Reads the next byte from the packet. Does not advance the position counter.
public PeekByte ( ) : byte
Результат byte
Пример #1
0
        internal bool TryInit(DataPacket initialPacket)
        {
            if (!Enumerable.SequenceEqual <byte>((IEnumerable <byte>)initialPacket.ReadBytes(7), (IEnumerable <byte>) new byte[7]
            {
                (byte)1,
                (byte)118,
                (byte)111,
                (byte)114,
                (byte)98,
                (byte)105,
                (byte)115
            }))
            {
                this._glueBits += (long)(initialPacket.Length * 8);
                return(false);
            }
            else
            {
                this._glueBits += 56L;
                this.ProcessStreamHeader(initialPacket);
                bool flag1 = false;
                bool flag2 = false;
                while (!(flag1 & flag2))
                {
                    DataPacket packet = this._getNextPacket();
                    if (packet.IsResync)
                    {
                        throw new InvalidDataException("Missing header packets!");
                    }
                    if (!this._pagesSeen.Contains(packet.PageSequenceNumber))
                    {
                        this._pagesSeen.Add(packet.PageSequenceNumber);
                    }
                    switch (packet.PeekByte())
                    {
                    case (byte)1:
                        throw new InvalidDataException("Found second init header!");

                    case (byte)3:
                        this.LoadComments(packet);
                        flag1 = true;
                        continue;

                    case (byte)5:
                        this.LoadBooks(packet);
                        flag2 = true;
                        continue;

                    default:
                        continue;
                    }
                }
                this.InitDecoder();
                return(true);
            }
        }
Пример #2
0
        private void NewStream(int streamSerial)
        {
            DataPacket nextPacket = this._packetProvider.GetNextPacket(streamSerial);

            if ((int)nextPacket.PeekByte() != (int)VorbisStreamDecoder.InitialPacketMarker)
            {
                return;
            }
            VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder((Func <DataPacket>)(() =>
            {
                IPacketProvider local_0 = this._packetProvider;
                if (local_0 != null)
                {
                    return(local_0.GetNextPacket(streamSerial));
                }
                else
                {
                    return((DataPacket)null);
                }
            }), (Func <int>)(() =>
            {
                IPacketProvider local_0 = this._packetProvider;
                if (local_0 != null)
                {
                    return(local_0.GetTotalPageCount(streamSerial));
                }
                else
                {
                    return(0);
                }
            }));

            try
            {
                if (!vorbisStreamDecoder.TryInit(nextPacket))
                {
                    return;
                }
                this._decoders.Add(vorbisStreamDecoder);
                this._serials.Add(streamSerial);
            }
            catch (InvalidDataException ex)
            {
            }
        }