Exemplo n.º 1
0
        /// <summary>
        ///		Add the XML content formatter.
        /// </summary>
        /// <param name="formatters">
        ///		The content formatter collection.
        /// </param>
        /// <returns>
        ///		The content formatter collection (enables method-chaining).
        /// </returns>
        public static IFormatterCollection AddXmlFormatter(this IFormatterCollection formatters)
        {
            if (formatters == null)
            {
                throw new ArgumentNullException(nameof(formatters));
            }

            formatters.Add(new XmlFormatter());

            return(formatters);
        }
Exemplo n.º 2
0
        /// <summary>
        ///		Add the JSON content formatter.
        /// </summary>
        /// <param name="formatters">
        ///		The content formatter collection.
        /// </param>
        /// <param name="serializerSettings">
        ///		Optional settings for the JSON serialiser.
        /// </param>
        /// <returns>
        ///		The content formatter collection (enables method-chaining).
        /// </returns>
        public static IFormatterCollection AddJsonFormatter(this IFormatterCollection formatters, JsonSerializerSettings serializerSettings = null)
        {
            if (formatters == null)
            {
                throw new ArgumentNullException(nameof(formatters));
            }

            formatters.Add(new JsonFormatter
            {
                SerializerSettings = serializerSettings
            });

            return(formatters);
        }