Пример #1
0
        /// <summary>
        /// Saves the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="format">The format.</param>
        public void Save(object value, Stream stream, IFormat format)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            ITypeWriter contentWriter = this.GetWriter(value.GetType());

            if (contentWriter.BypassFormat)
            {
                format = Format.None;
            }

            using (IFormatWriter formatWriter = format.CreateWriter(stream))
            {
                contentWriter.Write(formatWriter, value);
            }
        }