Table of Contents

Class MvcCoreBuilderExtensions

Namespace
Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml
Assembly
Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.dll

Extension methods for the IMvcCoreBuilder interface.

public static class MvcCoreBuilderExtensions
Inheritance
MvcCoreBuilderExtensions

Examples

The following example demonstrates how to add XML serialization formatters to an MVC core builder using the extension methods.

using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;

namespace MyApp.Examples;

public class MvcCoreBuilderExtensionsExample
{
    public void ConfigureMvc(IMvcCoreBuilder builder)
    {
        // Invoke the AddXmlFormatters extension method
        MvcCoreBuilderExtensions.AddXmlFormatters(builder, options =>
        {
            options.SynchronizeWithXmlConvert = true;
        });

        // Invoke the AddXmlFormattersOptions extension method
        MvcCoreBuilderExtensions.AddXmlFormattersOptions(builder, options =>
        {
            options.SynchronizeWithXmlConvert = true;
        });

}
}

Methods

AddXmlFormatters(IMvcCoreBuilder, Action<XmlFormatterOptions>)

Adds the XML serializer formatters to MVC.

public static IMvcCoreBuilder AddXmlFormatters(this IMvcCoreBuilder builder, Action<XmlFormatterOptions> setup = null)

Parameters

builder IMvcCoreBuilder

The IMvcCoreBuilder.

setup Action<XmlFormatterOptions>

The XmlFormatterOptions which may be configured.

Returns

IMvcCoreBuilder

A reference to builder after the operation has completed.

Exceptions

ArgumentNullException

builder cannot be null -or- setup cannot be null.

AddXmlFormattersOptions(IMvcCoreBuilder, Action<XmlFormatterOptions>)

Adds configuration of XmlFormatterOptions for the application.

public static IMvcCoreBuilder AddXmlFormattersOptions(this IMvcCoreBuilder builder, Action<XmlFormatterOptions> setup = null)

Parameters

builder IMvcCoreBuilder

The IMvcBuilder.

setup Action<XmlFormatterOptions>

The XmlFormatterOptions which need to be configured.

Returns

IMvcCoreBuilder

A reference to builder after the operation has completed.

Exceptions

ArgumentNullException

builder cannot be null.

ArgumentException

setup failed to configure an instance of XmlFormatterOptions in a valid state.