MvcCoreBuilderExtensions Class
Definition
- Namespace
- Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json
- Assemblies
- Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.dll
Extension methods for the IMvcCoreBuilder interface.
public static class MvcCoreBuilderExtensions
- Inheritance
-
objectMvcCoreBuilderExtensions
Examples
The following example demonstrates how to register JSON serialization formatters on an using the extension methods.
using System.Text.Json;
using System.Text.Json.Serialization;
using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;
using Microsoft.Extensions.DependencyInjection;
namespace DocfxExamples;
public class MvcCoreBuilderExtensionsExample
{
public void ConfigureMvc(IMvcCoreBuilder builder)
{
// Invoke the AddJsonFormatters extension method
builder.AddJsonFormatters(options =>
{
options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.Settings.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
// Invoke the AddJsonFormattersOptions extension method
builder.AddJsonFormattersOptions(options =>
{
options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});
}
}
Methods
| Name | Description |
|---|---|
| AddJsonFormatters(IMvcCoreBuilder, Action<JsonFormatterOptions>) | Adds the JSON serializer formatters to MVC. |
| AddJsonFormattersOptions(IMvcCoreBuilder, Action<JsonFormatterOptions>) | Adds configuration of JsonFormatterOptions for the application. |