Exemplo n.º 1
0
        public MsgPackReader(Stream stream, SerializationContext context, Endianness endianness = Endianness.BigEndian)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (!stream.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }

            this.Context         = context;
            this.inputStream     = stream;
            this.buffer          = new byte[8 * 1024];    // 8kb
            this.bufferOffset    = 0;
            this.bufferReaded    = 0;
            this.bufferAvailable = 0;
            this.bitConverter    = endianness == Endianness.BigEndian ? EndianBitConverter.Big : (EndianBitConverter)EndianBitConverter.Little;
            this.closingTokens   = new Stack <ClosingToken>();

            this.Value = new MsgPackValueInfo(this);
        }
        public MsgPackReader(Stream stream, SerializationContext context, Endianness endianness = Endianness.BigEndian, byte[] buffer = null)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (!stream.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }
            if (buffer != null && buffer.Length < 1024)
            {
                throw new ArgumentOutOfRangeException("buffer", "Buffer should be at least 1024 bytes long.");
            }

            this.Context         = context;
            this.inputStream     = stream;
            this.buffer          = buffer ?? new byte[DEFAULT_BUFFER_SIZE];
            this.bufferOffset    = 0;
            this.bufferRead      = 0;
            this.bufferAvailable = 0;
            this.bitConverter    = endianness == Endianness.BigEndian ? EndianBitConverter.Big : (EndianBitConverter)EndianBitConverter.Little;
            this.closingTokens   = new Stack <ClosingToken>();

            this.Value = new MsgPackValueInfo(this);
        }
Exemplo n.º 3
0
        public MsgPackReader(Stream stream, ISerializationContext context)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (!stream.CanRead)
            {
                throw new UnreadableStream("stream");
            }

            this.Context         = context;
            this.inputStream     = stream;
            this.buffer          = new byte[8 * 1024];    // 8kb
            this.bufferOffset    = 0;
            this.bufferReaded    = 0;
            this.bufferAvailable = 0;
            this.bitConverter    = EndianBitConverter.Little;
            this.closingTokens   = new Stack <ClosingToken>();

            this.Value = new MsgPackValueInfo(this);
        }