示例#1
0
        /// <summary>
        ///     Deserializes given type from stream.
        /// </summary>
        /// <typeparam name="T">deserialized value type.</typeparam>
        /// <param name="stream">source stream.</param>
        /// <param name="streamingContext">payload object for StreamingContext; defaults to null.</param>
        /// <param name="encoding">stream encoding; defaults to UTF8.</param>
        /// <param name="leaveOpen">leave stream open; defaults to false.</param>
        /// <returns>deserialized value.</returns>
        public T Deserialize <T>(Stream stream, Object streamingContext = null,
                                 Encoding encoding = null, bool leaveOpen = false)
        {
            var sc = Utils.GetStreamingContext(streamingContext);

            return(_serializer.Deserialize <T>(stream, streamingContext: sc.ToOption(),
                                               encoding: encoding.ToOption(), leaveOpen: leaveOpen.ToOption()));
        }
示例#2
0
        /// <summary>
        ///     Deserializes given type from stream.
        /// </summary>
        /// <typeparam name="T">deserialized value type.</typeparam>
        /// <param name="stream">source stream.</param>
        /// <param name="streamingContext">payload object for StreamingContext; defaults to null.</param>
        /// <param name="encoding">stream encoding; defaults to UTF8.</param>
        /// <param name="leaveOpen">leave stream open; defaults to false.</param>
        /// <returns>deserialized value.</returns>
        public T Deserialize <T>(Stream stream, Object streamingContext = null,
                                 Encoding encoding = null, bool leaveOpen = false)
        {
            var e  = Utils.GetEncoding(encoding);
            var sc = Utils.GetStreamingContext(streamingContext);
            var lo = Utils.GetLeaveOpen(leaveOpen);

            return(_pickler.Deserialize <T>(stream, sc, e, lo));
        }