예제 #1
0
        /// <summary>
        ///     Serializes given value to stream.
        /// </summary>
        /// <typeparam name="T">serialized value type.</typeparam>
        /// <param name="writer">target text writer.</param>
        /// <param name="value">serialized value.</param>
        /// <param name="streamingContext">payload object for StreamingContext; defaults to null.</param>
        /// <param name="leaveOpen">leave stream open; defaults to false.</param>
        public void Serialize <T>(TextWriter writer, T value, Object streamingContext = null, bool leaveOpen = false)
        {
            var sc = Utils.GetStreamingContext(streamingContext);
            var lo = Utils.GetLeaveOpen(leaveOpen);

            _textPickler.Serialize <T>(writer, value, streamingContext: sc, leaveOpen: lo);
        }
예제 #2
0
        /// <summary>
        ///     Serializes given value to stream.
        /// </summary>
        /// <typeparam name="T">serialized value type.</typeparam>
        /// <param name="writer">target text writer.</param>
        /// <param name="value">serialized value.</param>
        /// <param name="streamingContext">payload object for StreamingContext; defaults to null.</param>
        /// <param name="leaveOpen">leave stream open; defaults to false.</param>
        public void Serialize <T>(TextWriter writer, T value, Object streamingContext = null, bool leaveOpen = false)
        {
            var sc = Utils.GetStreamingContext(streamingContext);

            _textSerializer.Serialize <T>(writer, value, streamingContext: sc.ToOption(), leaveOpen: leaveOpen.ToOption());
        }