System.IO.MemoryStream.ReadByte C# (CSharp) Method

ReadByte() public method

public ReadByte ( ) : int
return int
        public override int ReadByte()
        {
            if (!_isOpen)
            {
                throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed);
            }

            if (_position >= _length)
            {
                return -1;
            }

            return _buffer[_position++];
        }

Usage Example

Exemplo n.º 1
0
        public override void ReadContents(byte[] bytes)
        {
            using (var ms = new MemoryStream(bytes))
            {
                if (ms.Length == 0)
                {
                    _emptyPayload = true;
                    Payload = new byte[] {};
                }
                else
                {
                    _emptyPayload = false;

                    var audioByte = (byte) ms.ReadByte();

                    _audioFormat = (AudioFormat) (audioByte >> 4 & 0x0f);
                    _audioRate = (AudioRate) (audioByte >> 2 & 0x03);
                    _audioSize = (AudioSize) (audioByte >> 1 & 0x01);
                    _audioType = (AudioType) (audioByte & 0x01);

                    if (_audioFormat == AudioFormat.AAC)
                    {
                        if (_audioRate == AudioRate._44kH || _audioType == AudioType.Stereo)
                        {
                            _aacPacketType = (AACPacketType) ms.ReadByte();
                        }
                    }

                    Payload = new byte[ms.Length - ms.Position];
                    ms.Read(Payload, 0, Payload.Length);
                }
            }
        }
All Usage Examples Of System.IO.MemoryStream::ReadByte