feat: Add LuckyPennySoft license key configuration for AutoMapper and MediatR
- Add license key reading from appsettings.json - Configure AutoMapper 16.2.0+ with built-in DI extension and license key - Configure MediatR 14.2.0+ with license key - Update Program.cs to pass IConfiguration to AddApplicationServices
This commit is contained in:
@@ -38,7 +38,7 @@ try
|
|||||||
builder.Configuration.AddJsonFile("appsettings.Secrets.json", optional: true, reloadOnChange: true);
|
builder.Configuration.AddJsonFile("appsettings.Secrets.json", optional: true, reloadOnChange: true);
|
||||||
|
|
||||||
// Register Application layer (MediatR, AutoMapper, FluentValidation)
|
// Register Application layer (MediatR, AutoMapper, FluentValidation)
|
||||||
builder.Services.AddApplicationServices();
|
builder.Services.AddApplicationServices(builder.Configuration);
|
||||||
|
|
||||||
// Register Infrastructure layer (RabbitMQ, Repositories, etc.)
|
// Register Infrastructure layer (RabbitMQ, Repositories, etc.)
|
||||||
builder.Services.AddInfrastructure(builder.Configuration);
|
builder.Services.AddInfrastructure(builder.Configuration);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace DigitalData.EmailProfiler.Application;
|
namespace DigitalData.EmailProfiler.Application;
|
||||||
@@ -9,18 +10,27 @@ namespace DigitalData.EmailProfiler.Application;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DependencyInjection
|
public static class DependencyInjection
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddApplicationServices(this IServiceCollection services)
|
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
// Read LuckyPennySoft license key from appsettings.json
|
||||||
|
var licenseKey = configuration.GetValue<string>("LuckyPennySoftLicenseKey")
|
||||||
|
?? throw new InvalidOperationException("LuckyPennySoftLicenseKey not found in configuration");
|
||||||
|
|
||||||
// MediatR - Register all handlers
|
// MediatR - Register all handlers
|
||||||
services.AddMediatR(config =>
|
services.AddMediatR(config =>
|
||||||
{
|
{
|
||||||
|
config.LicenseKey = licenseKey;
|
||||||
config.RegisterServicesFromAssembly(assembly);
|
config.RegisterServicesFromAssembly(assembly);
|
||||||
});
|
});
|
||||||
|
|
||||||
// AutoMapper - Register all profiles
|
// AutoMapper - Use built-in DI extension (AutoMapper 16.2.0+)
|
||||||
services.AddAutoMapper(assembly);
|
services.AddAutoMapper(config =>
|
||||||
|
{
|
||||||
|
config.LicenseKey = licenseKey;
|
||||||
|
config.AddMaps(assembly);
|
||||||
|
});
|
||||||
|
|
||||||
// FluentValidation - Register all validators
|
// FluentValidation - Register all validators
|
||||||
services.AddValidatorsFromAssembly(assembly);
|
services.AddValidatorsFromAssembly(assembly);
|
||||||
|
|||||||
Reference in New Issue
Block a user