Exemple #1
0
        public static object Deserialize(Type objectType, Stream msgPackInput, SerializationContext context)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException("objectType");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (msgPackInput == null)
            {
                throw new ArgumentNullException("msgPackInput");
            }

            if (!msgPackInput.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }

            // fix
            // var reader = new MsgPackReader(msgPackInput, context);
            // return reader.ReadValue(objectType, false);
            var reader = new MsgPackFixReader(msgPackInput, context);

            return(reader.ReadValue(objectType, false));
        }
Exemple #2
0
        public JsonStreamReader(Stream stream, SerializationContext context, char[] buffer = null)
            : base(context, buffer)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (!stream.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }

            this.reader = new StreamReader(stream, context.Encoding);
        }
        public JsonStreamReader(Stream stream, SerializationContext context, int bufferSize = DEFAULT_BUFFER_SIZE)
            : base(context, bufferSize)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (!stream.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }


            reader = new StreamReader(stream, context.Encoding);
        }
Exemple #4
0
        public static T Deserialize <T>(Stream msgPackInput, SerializationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (msgPackInput == null)
            {
                throw new ArgumentNullException("msgPackInput");
            }
            if (!msgPackInput.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }

            return((T)Deserialize(typeof(T), msgPackInput, context));
        }
Exemple #5
0
        public static object Deserialize(Type objectType, Stream jsonStream, SerializationContext context)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException("objectType");
            }
            if (jsonStream == null)
            {
                throw new ArgumentNullException("jsonStream");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (!jsonStream.CanRead)
            {
                throw JsonSerializationException.StreamIsNotReadable();
            }

            var reader = new JsonStreamReader(jsonStream, context);

            return(reader.ReadValue(objectType, false));
        }