Table of Contents

Class ServiceCollectionExtensions

Namespace
Cuemon.Extensions.AspNetCore.Newtonsoft.Json.Formatters
Assembly
Cuemon.Extensions.AspNetCore.Newtonsoft.Json.dll

Extension methods for the Microsoft.Extensions.DependencyInjection.IServiceCollection interface.

public static class ServiceCollectionExtensions
Inheritance
Object
ServiceCollectionExtensions

Methods

AddNewtonsoftJsonExceptionResponseFormatter(IServiceCollection, Action<NewtonsoftJsonFormatterOptions>)

Adds an IHttpExceptionDescriptorResponseFormatter that uses NewtonsoftJsonFormatter as engine of serialization to the specified list of services.

public static IServiceCollection AddNewtonsoftJsonExceptionResponseFormatter(this IServiceCollection services, Action<NewtonsoftJsonFormatterOptions> setup = null)

Parameters

services IServiceCollection

The Microsoft.Extensions.DependencyInjection.IServiceCollection to extend.

setup Action<NewtonsoftJsonFormatterOptions>

The NewtonsoftJsonFormatterOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional calls can be chained.

Remarks

Configuration of the NewtonsoftJsonFormatter is done through a call to Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService``1(System.IServiceProvider) retrieving an Microsoft.Extensions.Options.IOptions<TOptions> implementation of NewtonsoftJsonFormatterOptions.

Exceptions

System.ArgumentNullException

services cannot be null

AddNewtonsoftJsonFormatterOptions(IServiceCollection, Action<NewtonsoftJsonFormatterOptions>)

Adds configuration of NewtonsoftJsonFormatterOptions for the application.

public static IServiceCollection AddNewtonsoftJsonFormatterOptions(this IServiceCollection services, Action<NewtonsoftJsonFormatterOptions> setup = null)

Parameters

services IServiceCollection

The Microsoft.Extensions.DependencyInjection.IServiceCollection to extend.

setup Action<NewtonsoftJsonFormatterOptions>

The NewtonsoftJsonFormatterOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Exceptions

System.ArgumentNullException

services cannot be null.

System.ArgumentException

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