Read() public static method

public static Read ( BinaryReader reader ) : BerValue
reader System.IO.BinaryReader
return BerValue
示例#1
0
        private BerValue ReadBerValue()
        {
            Int32 lCode = fCurrentConnection.ReadByte();

            if (lCode < 0)
            {
                throw new ConnectionClosedException();
            }

            Int32 lLength = fCurrentConnection.ReadByte();

            if (lLength < 0)
            {
                throw new ConnectionClosedException();
            }

            if (lLength >= 0x80)
            {
                Byte[] lBuffer = new Byte[lLength & ~0x80];
                fCurrentConnection.Read(lBuffer, 0, lBuffer.Length);
                lLength = 0;
                for (Int32 i = 0; i < lBuffer.Length; i++)
                {
                    lLength = lLength << 8 | lBuffer[i];
                }
            }

            Byte[] lData = new Byte[lLength];
            fCurrentConnection.Read(lData, 0, lData.Length);

            return(BerValue.Read(lData, lLength, (Byte)lCode));
        }
示例#2
0
        protected override void IntRead(BinaryReader reader, Byte code, Int32 length)
        {
            this.TypeCodeTag = code;
            Byte[] lData = reader.Read(length);
            this.fItems.RemoveAll();

            BinaryReader lReader = new BinaryReader(new MemoryStream(lData, false));

            while (lReader.PeekChar() >= 0)
            {
                this.fItems.Add(BerValue.Read(lReader));
            }
        }