diff --git a/src/core/DigitalData.TaskFlow.Application/DependencyInjection.cs b/src/core/DigitalData.TaskFlow.Application/DependencyInjection.cs index c51876f..840ce5e 100644 --- a/src/core/DigitalData.TaskFlow.Application/DependencyInjection.cs +++ b/src/core/DigitalData.TaskFlow.Application/DependencyInjection.cs @@ -1,5 +1,9 @@ -using Microsoft.Extensions.Configuration; +using DigitalData.TaskFlow.Application.Options; +using FluentValidation; +using MediatR; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using System.Reflection; namespace DigitalData.TaskFlow.Application; @@ -7,8 +11,27 @@ public static class DependencyInjection { public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration) { - // Register application services here - // Example: services.AddSingleton(); + var mediatROptions = configuration + .GetSection(MediatROptions.SectionName) + .Get(); + + services + .AddOptions() + .Bind(configuration.GetSection(MediatROptions.SectionName)); + + services.AddMediatR(config => + { + config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly); + + if (!string.IsNullOrWhiteSpace(mediatROptions?.LuckyPennySoftLicenseKey)) + { + config.LicenseKey = mediatROptions.LuckyPennySoftLicenseKey; + } + }); + + services.AddValidatorsFromAssembly(typeof(DependencyInjection).Assembly); + services.AddAutoMapper(_ => { }, Assembly.GetExecutingAssembly()); + return services; } } diff --git a/src/core/DigitalData.TaskFlow.Application/DigitalData.TaskFlow.Application.csproj b/src/core/DigitalData.TaskFlow.Application/DigitalData.TaskFlow.Application.csproj index ab7cc5f..a25cdc3 100644 --- a/src/core/DigitalData.TaskFlow.Application/DigitalData.TaskFlow.Application.csproj +++ b/src/core/DigitalData.TaskFlow.Application/DigitalData.TaskFlow.Application.csproj @@ -7,8 +7,13 @@ - - + + + + + + + diff --git a/src/core/DigitalData.TaskFlow.Application/Options/MediatROptions.cs b/src/core/DigitalData.TaskFlow.Application/Options/MediatROptions.cs new file mode 100644 index 0000000..a11efff --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Application/Options/MediatROptions.cs @@ -0,0 +1,8 @@ +namespace DigitalData.TaskFlow.Application.Options; + +public sealed class MediatROptions +{ + public const string SectionName = "MediatR"; + + public string? LuckyPennySoftLicenseKey { get; init; } +} diff --git a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DependencyInjection.cs b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DependencyInjection.cs index c2a1f5e..ad24efc 100644 --- a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DependencyInjection.cs +++ b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DependencyInjection.cs @@ -7,8 +7,6 @@ public static class DependencyInjection { public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, IConfiguration configuration) { - // Register infrastructure services here - // Example: services.AddSingleton(); return services; } } diff --git a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DigitalData.TaskFlow.Infrastructure.csproj b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DigitalData.TaskFlow.Infrastructure.csproj index 85f39f8..4d4386b 100644 --- a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DigitalData.TaskFlow.Infrastructure.csproj +++ b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/DigitalData.TaskFlow.Infrastructure.csproj @@ -7,8 +7,11 @@ - - + + + + + @@ -16,4 +19,8 @@ + + + + diff --git a/src/presentation/DigitalData.TaskFlow.API/DigitalData.TaskFlow.API.csproj b/src/presentation/DigitalData.TaskFlow.API/DigitalData.TaskFlow.API.csproj index 3b59ea3..38ffb2a 100644 --- a/src/presentation/DigitalData.TaskFlow.API/DigitalData.TaskFlow.API.csproj +++ b/src/presentation/DigitalData.TaskFlow.API/DigitalData.TaskFlow.API.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -7,7 +7,8 @@ - + + diff --git a/src/presentation/DigitalData.TaskFlow.API/Options/SwaggerOptions.cs b/src/presentation/DigitalData.TaskFlow.API/Options/SwaggerOptions.cs new file mode 100644 index 0000000..608f789 --- /dev/null +++ b/src/presentation/DigitalData.TaskFlow.API/Options/SwaggerOptions.cs @@ -0,0 +1,8 @@ +namespace DigitalData.TaskFlow.API.Options; + +public sealed class SwaggerOptions +{ + public const string SectionName = "Swagger"; + + public bool EnabledInProduction { get; init; } +} diff --git a/src/presentation/DigitalData.TaskFlow.API/appsettings.json b/src/presentation/DigitalData.TaskFlow.API/appsettings.json index 10f68b8..3f3cd8f 100644 --- a/src/presentation/DigitalData.TaskFlow.API/appsettings.json +++ b/src/presentation/DigitalData.TaskFlow.API/appsettings.json @@ -1,4 +1,13 @@ { + "ConnectionStrings": { + "TaskFlowDb": "Server=SDD-VHP04-SQL19\\DD_TESTING01;Database=DD_ECM;User Id=sa;Password=123456789dD!;Encrypt=false;TrustServerCertificate=True;" + }, + "MediatR": { + "LuckyPennySoftLicenseKey": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxODE2MTI4MDAwIiwiaWF0IjoiMTc4NDYyNDU1NyIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiMDE5ODNjNTllNGIzNzI4ZWJmZDMxMDNjMmE0ODZlODUiLCJzdWJfaWQiOiItIiwiZWRpdGlvbiI6IjAiLCJ0eXBlIjoiMiJ9.IUUO926m9crYGYxMjjKD_n9BnUm-EDyjFIn0YmMUCo7C-QTwvB8WhXP8veTSFsBq-leIIDJ4jyl7Pgc_7ciwg1XhUSIs4mkQroEUaSFCGOxw7Pi41WM8MK5YFSaqLTYYXec9zxgiJbGzABbh3CHTSup3okGnVm_CMoPEs91l2c0A6N1JyZy74urd_tF0KGVKf0MOvzdlQIWLQ8o73S4pTv2N-F6UlzI0fdMtTHMLNNQyr0NdWdnuBk_jMBXO-gy5RE_oCRfMTTYRX2n3XLK6pTfXE0Ct338o9F5sH8Ph2lTXSu56cpdsfZOQZGqCH0LoFp1Dd7RJgIgNmBiTGfvDnA" + }, + "Swagger": { + "EnabledInProduction": false + }, "Logging": { "LogLevel": { "Default": "Information",