Esempio n. 1
0
        public T DeserializeFromStream <T>(Stream stream)
        {
            if (TextSerializer != null)
            {
                return(TextSerializer.DeserializeFromStream <T>(stream));
            }

            if (UseBcl)
            {
                var serializer = new DataContractJsonSerializer(typeof(T));
                return((T)serializer.ReadObject(stream));
            }
            return(JsonSerializer.DeserializeFromStream <T>(stream));
        }
Esempio n. 2
0
        public object DeserializeFromStream(Type type, Stream stream)
        {
            if (TextSerializer != null)
            {
                return(TextSerializer.DeserializeFromStream(type, stream));
            }

            if (UseBcl)
            {
                var serializer = new DataContractJsonSerializer(type);
                return(serializer.ReadObject(stream));
            }
            return(JsonSerializer.DeserializeFromStream(type, stream));
        }
        /// <summary>Deserialize from stream.</summary>
        ///
        /// <typeparam name="T">Generic type parameter.</typeparam>
        /// <param name="stream">The stream.</param>
        ///
        /// <returns>A T.</returns>
        public T DeserializeFromStream <T>(Stream stream)
        {
            if (TextSerializer != null)
            {
                return(TextSerializer.DeserializeFromStream <T>(stream));
            }

#if !SILVERLIGHT && !MONOTOUCH && !XBOX && !ANDROIDINDIE
            if (UseBcl)
            {
                var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T));
                return((T)serializer.ReadObject(stream));
            }
#endif
            return(JsonSerializer.DeserializeFromStream <T>(stream));
        }
Esempio n. 4
0
        public object DeserializeFromStream(Type type, Stream stream)
        {
            if (TextSerializer != null)
            {
                return(TextSerializer.DeserializeFromStream(type, stream));
            }

#if !SILVERLIGHT && !MONOTOUCH && !XBOX && !NETCF
            if (UseBcl)
            {
                var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(type);
                return(serializer.ReadObject(stream));
            }
#endif

            return(JsonSerializer.DeserializeFromStream(type, stream));
        }