From 7316343658a512bb52a6217e097e219f26d128c1 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 8 Nov 2024 16:11:48 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Hinzuf=C3=BCgen=20von=20Newtonsoft.Json?= =?UTF-8?q?=20Unterst=C3=BCtzung=20und=20Entfernen=20von=20doppelten=20Con?= =?UTF-8?q?troller-Konfigurationen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Hinzugefügt: Newtonsoft.Json zur Projektdatei und konfiguriert, um UTC für DateTime-Serialisierung zu verwenden. - Entfernt: Doppelte Controller-Konfiguration für das Hinzufügen von Conventions. - Aktualisiert: Projektdatei mit neuen Paketreferenzen für Newtonsoft.Json und Microsoft.AspNetCore.Mvc.NewtonsoftJson. --- .../DigitalData.UserManager.API.csproj | 2 ++ DigitalData.UserManager.API/Program.cs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DigitalData.UserManager.API/DigitalData.UserManager.API.csproj b/DigitalData.UserManager.API/DigitalData.UserManager.API.csproj index 292e356..45cb749 100644 --- a/DigitalData.UserManager.API/DigitalData.UserManager.API.csproj +++ b/DigitalData.UserManager.API/DigitalData.UserManager.API.csproj @@ -40,6 +40,7 @@ + @@ -48,6 +49,7 @@ + diff --git a/DigitalData.UserManager.API/Program.cs b/DigitalData.UserManager.API/Program.cs index eef8e0b..f6bdbef 100644 --- a/DigitalData.UserManager.API/Program.cs +++ b/DigitalData.UserManager.API/Program.cs @@ -9,6 +9,7 @@ using DigitalData.Core.API; using DigitalData.UserManager.API.Controllers; using DigitalData.UserManager.Application.Services; using Microsoft.Data.SqlClient; +using Newtonsoft.Json; var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger(); logger.Debug("init main"); @@ -25,8 +26,16 @@ try { builder.Logging.ClearProviders(); builder.Host.UseNLog(); - - builder.Services.AddControllers(); + + builder.Services.AddControllers(opt => + { + opt.Conventions.Add(new RemoveIfControllerConvention() + .AndIf(c => c.ControllerName == nameof(EncryptionController).Replace("Controller", "")) + .AndIf(c => !config.GetValue("UseEncryptor"))); + }).AddNewtonsoftJson(options => + { + options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; + }); if (builder.Configuration.GetValue("UseSwagger")) {