예제 #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));
        }
예제 #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);
        }
예제 #3
0
        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);
        }
예제 #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));
        }
예제 #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));
        }