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
This commit is contained in:
@@ -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
|
||||
/// <summary>
|
||||
/// Registers Application Layer services (MediatR, FluentValidation, AutoMapper, Behaviors)
|
||||
/// </summary>
|
||||
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<string>("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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user