From 97122d0bbdd110ea739de4cb5217bab0ceb8cae3 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 21 Jul 2026 16:52:27 +0200 Subject: [PATCH] feat(license): Configure MediatR + AutoMapper with LuckyPennySoft license - Read LuckyPennySoftLicenseKey from appsettings.json - Set MediatR config.LicenseKey - Set AutoMapper cfg.LicenseKey - AddApplication now requires IConfiguration parameter --- DocumentOperator.Application/DependencyInjection.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/DocumentOperator.Application/DependencyInjection.cs b/DocumentOperator.Application/DependencyInjection.cs index 4addee1..5f59e2a 100644 --- a/DocumentOperator.Application/DependencyInjection.cs +++ b/DocumentOperator.Application/DependencyInjection.cs @@ -1,4 +1,5 @@ using FluentValidation; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace DocumentOperator.Application; @@ -11,13 +12,18 @@ public static class DependencyInjection /// /// Registers Application Layer services (MediatR, FluentValidation, AutoMapper, Behaviors) /// - public static IServiceCollection AddApplication(this IServiceCollection services) + public static IServiceCollection AddApplication(this IServiceCollection services, IConfiguration configuration) { var assembly = typeof(DependencyInjection).Assembly; + // Read LuckyPennySoft license key from appsettings.json + var licenseKey = configuration.GetValue("LuckyPennySoftLicenseKey") + ?? throw new InvalidOperationException("LuckyPennySoftLicenseKey not found in configuration"); + // Register MediatR (scannt Assembly nach Handlers) services.AddMediatR(config => { + config.LicenseKey = licenseKey; config.RegisterServicesFromAssembly(assembly); // Pipeline Behaviors (Reihenfolge wichtig!) @@ -29,7 +35,9 @@ public static class DependencyInjection services.AddValidatorsFromAssembly(assembly); // Register AutoMapper (scannt Assembly nach Profiles) - services.AddAutoMapper(cfg => { }, typeof(Common.Mapping.MappingProfile)); + services.AddAutoMapper(cfg => { + cfg.LicenseKey = licenseKey; + }, typeof(Common.Mapping.MappingProfile)); return services; }