MvcBuilderExtensions Class
Definition
- Namespace
- Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml
- Assemblies
- Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.dll
Extension methods for the IMvcBuilder interface.
public static class MvcBuilderExtensions
- Inheritance
-
objectMvcBuilderExtensions
Examples
The following example demonstrates how to add XML serialization formatters to an MVC builder. It calls AddXmlFormatters with indentation enabled, then AddXmlFormattersOptions with indentation disabled, on the builder returned by AddControllers. Both calls configure the underlying XmlWriter settings, showing how to register and customize XML input/output formatters for ASP.NET Core API controllers.
using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;
using Microsoft.Extensions.DependencyInjection;
namespace MyApp.Examples
{
public static class MvcBuilderExtensionsExample
{
public static void ConfigureServices(IServiceCollection services)
{
var builder = services.AddControllers();
builder.AddXmlFormatters(options =>
{
options.Settings.Writer.Indent = true;
});
builder.AddXmlFormattersOptions(options =>
{
options.Settings.Writer.Indent = false;
});
}
}
}
Methods
| Name | Description |
|---|---|
| AddXmlFormatters(IMvcBuilder, Action<XmlFormatterOptions>) | Adds the XML serializer formatters to MVC. |
| AddXmlFormattersOptions(IMvcBuilder, Action<XmlFormatterOptions>) | Adds configuration of XmlFormatterOptions for the application. |