ServiceCollectionExtensions Class
Definition
- Namespace
- Savvyio.Extensions.DependencyInjection.Text.Json
- Assemblies
- Savvyio.Extensions.DependencyInjection.Text.Json.dll
Extension methods for the IServiceCollection interface.
public static class ServiceCollectionExtensions
- Inheritance
-
objectServiceCollectionExtensions
Examples
Register JsonMarshaller in the DI container with AddJsonMarshaller.
using System.Text.Json;
using Microsoft.Extensions.DependencyInjection;
using Savvyio.Extensions.DependencyInjection.Text.Json;
namespace ExampleApp;
public static class JsonDependencyInjectionSetup
{
public static IServiceCollection AddSystemTextJsonSerialization(this IServiceCollection services)
{
services.AddJsonMarshaller(options =>
{
options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.Settings.WriteIndented = true;
});
return services;
}
}
Methods
| Name | Description |
|---|---|
| AddJsonMarshaller(IServiceCollection, Action<JsonFormatterOptions>, Action<ServiceOptions>) | Adds an JsonMarshaller implementation to the specified IServiceCollection. |