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
builderIMvcCoreBuilderThe IMvcCoreBuilder.
setupAction<XmlFormatterOptions>The XmlFormatterOptions which may be configured.
Returns
- IMvcCoreBuilder
A reference to
builderafter the operation has completed.
Exceptions
- ArgumentNullException
buildercannot be null -or-setupcannot 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
builderIMvcCoreBuilderThe IMvcBuilder.
setupAction<XmlFormatterOptions>The XmlFormatterOptions which need to be configured.
Returns
- IMvcCoreBuilder
A reference to
builderafter the operation has completed.
Exceptions
- ArgumentNullException
buildercannot be null.- ArgumentException
setupfailed to configure an instance of XmlFormatterOptions in a valid state.