/// <summary>
        /// Initializes a new instance of <see cref="XmlSerializerMvcOptionsSetup "/>.
        /// </summary>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
        public XmlSerializerMvcOptionsSetup(XmlSerializerFormatterOptions options, ILoggerFactory loggerFactory)
        {
            ArgCheck.NotNull(nameof(loggerFactory), loggerFactory);

            _options       = options;
            _loggerFactory = loggerFactory;
        }
        /// <summary>
        /// Adds the XML Serializer formatters to MVC.
        /// </summary>
        /// <param name="builder">The <see cref="IMvcBuilder"/>.</param>
        /// <returns>The <see cref="IMvcBuilder"/>.</returns>
        public static IMvcBuilder AddXmlSerializerFormatters(this IMvcBuilder builder, XmlSerializerFormatterOptions options)
        {
            ArgCheck.NotNull(nameof(builder), builder);

            MvcCoreBuilderExtensions.AddXmlSerializerFormatterServices(builder.Services, options);
            return builder;
        }
Exemple #3
0
 // Internal for testing.
 internal static void AddXmlSerializerFormatterServices(IServiceCollection services, XmlSerializerFormatterOptions options)
 {
     services.AddSingleton(options);
     services.TryAddEnumerable(
         ServiceDescriptor.Transient <IConfigureOptions <MvcOptions>, XmlSerializerMvcOptionsSetup>());
 }