Class ServiceCollectionExtensions
- Assembly
- Codebelt.Extensions.AspNetCore.Newtonsoft.Json.dll
Extension methods for the IServiceCollection interface.
public static class ServiceCollectionExtensions
- Inheritance
-
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
IServiceCollectionThe 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 GetService<T>(IServiceProvider) retrieving an IOptions<TOptions> implementation of NewtonsoftJsonFormatterOptions.
Exceptions
- 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
IServiceCollectionThe 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
- ArgumentNullException
services
cannot be null.- ArgumentException
setup
failed to configure an instance of NewtonsoftJsonFormatterOptions in a valid state.