From 365f20dbab65c694210a4212bf8af292266d21d3 Mon Sep 17 00:00:00 2001 From: Luciana Regina Lino Date: Mon, 17 Jun 2024 14:22:59 -0300 Subject: [PATCH] wip(Liquid.Core, Liquid.WebApi.Http): Update Liquid framework for net8. --- src/Liquid.Core/Liquid.Core.csproj | 4 ++- .../Exceptions/LiquidContextKeysException.cs | 5 --- .../Exceptions/LiquidScopedKeysException.cs | 4 --- .../IApplicationBuilderExtensions.cs | 5 ++- .../IServiceCollectionExtensions.cs | 33 ++++++++++++++++--- .../Liquid.WebApi.Http.csproj | 9 ++--- .../Liquid.WebApi.Http.Tests.csproj | 12 +++---- 7 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/Liquid.Core/Liquid.Core.csproj b/src/Liquid.Core/Liquid.Core.csproj index 7f3f2511..e40ff42b 100644 --- a/src/Liquid.Core/Liquid.Core.csproj +++ b/src/Liquid.Core/Liquid.Core.csproj @@ -10,7 +10,7 @@ Avanade 2019 https://github.com/Avanade/Liquid-Application-Framework logo.png - 8.0.0-alpha-03 + 8.0.0-alpha-04 true {C33A89FC-4F4D-4274-8D0F-29456BA8F76B} true @@ -26,9 +26,11 @@ + + diff --git a/src/Liquid.WebApi.Http/Exceptions/LiquidContextKeysException.cs b/src/Liquid.WebApi.Http/Exceptions/LiquidContextKeysException.cs index 95dce0f5..863f3c75 100644 --- a/src/Liquid.WebApi.Http/Exceptions/LiquidContextKeysException.cs +++ b/src/Liquid.WebApi.Http/Exceptions/LiquidContextKeysException.cs @@ -24,10 +24,5 @@ public LiquidContextKeysException(string contextKey) : base($"The value of requi public LiquidContextKeysException(string message, Exception innerException) : base(message, innerException) { } - - /// - protected LiquidContextKeysException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } diff --git a/src/Liquid.WebApi.Http/Exceptions/LiquidScopedKeysException.cs b/src/Liquid.WebApi.Http/Exceptions/LiquidScopedKeysException.cs index e771840c..f8f6943b 100644 --- a/src/Liquid.WebApi.Http/Exceptions/LiquidScopedKeysException.cs +++ b/src/Liquid.WebApi.Http/Exceptions/LiquidScopedKeysException.cs @@ -25,9 +25,5 @@ public LiquidScopedtKeysException(string message, Exception innerException) : ba { } - /// - protected LiquidScopedtKeysException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } diff --git a/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IApplicationBuilderExtensions.cs b/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IApplicationBuilderExtensions.cs index f4819316..e13f3c73 100644 --- a/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IApplicationBuilderExtensions.cs +++ b/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IApplicationBuilderExtensions.cs @@ -1,10 +1,9 @@ -using System.Diagnostics.CodeAnalysis; -using Liquid.Core.Interfaces; -using Liquid.WebApi.Http.Middlewares; +using Liquid.WebApi.Http.Middlewares; using Liquid.WebApi.Http.Settings; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using System.Diagnostics.CodeAnalysis; namespace Liquid.WebApi.Http.Extensions.DependencyInjection { diff --git a/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IServiceCollectionExtensions.cs b/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IServiceCollectionExtensions.cs index 0f18f173..03c9bd54 100644 --- a/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IServiceCollectionExtensions.cs +++ b/src/Liquid.WebApi.Http/Extensions/DependencyInjection/IServiceCollectionExtensions.cs @@ -3,6 +3,7 @@ using Liquid.Core.Extensions.DependencyInjection; using Liquid.Core.Implementations; using Liquid.Core.Interfaces; +using Liquid.Core.Settings; using Liquid.WebApi.Http.Filters.Swagger; using Liquid.WebApi.Http.Settings; using Microsoft.Extensions.Configuration; @@ -25,23 +26,47 @@ public static class IServiceCollectionExtensions { /// /// Registers a service and execute registration methods - /// set mapping , + /// set mapping , /// register domain handlers , /// and swagger /// /// Extended service collection instance. /// Array of assemblies that the domain handlers are implemented. /// Swagger configuration section name. - public static IServiceCollection AddLiquidHttp(this IServiceCollection services, string sectionName, params Assembly[] assemblies) + /// Indicates if middlewares options must be binded. + public static IServiceCollection AddLiquidHttp(this IServiceCollection services, string sectionName, bool middlewares = false, params Assembly[] assemblies) { + if (middlewares) + { + services.AddOptions() + .Configure((settings, configuration) => + { + configuration.GetSection(sectionName + ":ScopedContext").Bind(settings); + }); + + services.AddOptions() + .Configure((settings, configuration) => + { + configuration.GetSection(sectionName + ":Culture").Bind(settings); + }); + + services.AddOptions() + .Configure((settings, configuration) => + { + configuration.GetSection(sectionName + ":ScopedLogging").Bind(settings); + }); + } + services.AddScoped(); services.AddLiquidSerializers(); + services.AddOptions() .Configure((settings, configuration) => { - configuration.GetSection(sectionName).Bind(settings); + configuration.GetSection(sectionName + ":Swagger").Bind(settings); }); - services.AddAutoMapper(assemblies); + + services.LiquidAddAutoMapper(assemblies); services.AddLiquidHandlers(true, true, assemblies); services.AddLiquidSwagger(); diff --git a/src/Liquid.WebApi.Http/Liquid.WebApi.Http.csproj b/src/Liquid.WebApi.Http/Liquid.WebApi.Http.csproj index 7335e281..95542b7a 100644 --- a/src/Liquid.WebApi.Http/Liquid.WebApi.Http.csproj +++ b/src/Liquid.WebApi.Http/Liquid.WebApi.Http.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 Liquid.WebApi.Http MIT Avanade Brazil @@ -10,7 +10,7 @@ Avanade 2019 https://github.com/Avanade/Liquid-Application-Framework logo.png - 6.0.1 + 8.0.0-alpha-01 true true Full @@ -23,6 +23,7 @@ + @@ -33,8 +34,4 @@ - - - - diff --git a/test/Liquid.WebApi.Http.Tests/Liquid.WebApi.Http.Tests.csproj b/test/Liquid.WebApi.Http.Tests/Liquid.WebApi.Http.Tests.csproj index 4bca361c..4ec40275 100644 --- a/test/Liquid.WebApi.Http.Tests/Liquid.WebApi.Http.Tests.csproj +++ b/test/Liquid.WebApi.Http.Tests/Liquid.WebApi.Http.Tests.csproj @@ -1,20 +1,20 @@  - net6.0 + net8.0 false - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all