mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.3 KiB
36 lines
1.3 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Microsoft.Extensions.Options;
|
|
using Volo.Abp.Json.Newtonsoft;
|
|
using Volo.Abp.Json.SystemTextJson;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.Timing;
|
|
|
|
namespace Volo.Abp.Json
|
|
{
|
|
[DependsOn(typeof(AbpTimingModule))]
|
|
public class AbpJsonModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
context.Services.TryAddEnumerable(ServiceDescriptor
|
|
.Transient<IConfigureOptions<AbpSystemTextJsonSerializerOptions>, AbpSystemTextJsonSerializerOptionsSetup>());
|
|
|
|
var preActions = context.Services.GetPreConfigureActions<AbpJsonOptions>();
|
|
Configure<AbpJsonOptions>(options =>
|
|
{
|
|
options.Providers.Add<AbpNewtonsoftJsonSerializerProvider>();
|
|
if (preActions.Configure().UseHybridSerializer)
|
|
{
|
|
options.Providers.Add<AbpSystemTextJsonSerializerProvider>();
|
|
}
|
|
});
|
|
|
|
Configure<AbpNewtonsoftJsonSerializerOptions>(options =>
|
|
{
|
|
options.Converters.Add<AbpJsonIsoDateTimeConverter>();
|
|
});
|
|
}
|
|
}
|
|
}
|