using Gatedge.ScanCode.Services; using Gatedge.ScanCode.Services.IServices; using Microsoft.AspNetCore.Authorization; using System.Text.Json; namespace Gatedge.ScanCode.Extension { /// /// 服务扩展 /// public static class ServiceExtension { /// /// 添加MVC服务,并配置默认的输出格式为JSON /// /// public static void ConfigureServices(this IServiceCollection services) { // 添加MVC服务,并配置默认的输出格式为JSON services.AddControllers().AddJsonOptions(options => { // 可以在这里配置JSON序列化选项,例如日期格式、驼峰命名等 options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; options.JsonSerializerOptions.WriteIndented = true; }); } /// /// 注册Bean服务 /// /// public static void ConfigureCore(this IServiceCollection service) { service.AddSingleton(); service.AddTransient(); } } }