Files
DocumentService/DocumentService.Application/DependencyInjection.cs
TekH 207c778f3a Refactor: Rename DocumentOperator to DocumentService
Updated project and solution files to rename and restructure
`DocumentOperator` to `DocumentService`. Modified project
references in `DocumentService.API.csproj`, `DocumentService.Application.csproj`,
and `DocumentService.Infrastructure.csproj` to reflect the new
naming convention. Updated `DocumentService.sln` to remove
old project references, add new ones, and adjust configuration
and nested project mappings accordingly. This change aligns
the project structure with the new naming convention.
2026-08-30 21:33:25 +02:00

45 lines
1.6 KiB
C#

using FluentValidation;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace DocumentService.Application;
/// <summary>
/// Dependency Injection configuration for Application Layer
/// </summary>
public static class DependencyInjection
{
/// <summary>
/// Registers Application Layer services (MediatR, FluentValidation, AutoMapper, Behaviors)
/// </summary>
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!)
config.AddOpenBehavior(typeof(Common.Behaviors.ValidationBehavior<,>));
config.AddOpenBehavior(typeof(Common.Behaviors.LoggingBehavior<,>));
});
// Register FluentValidation (scannt Assembly nach Validators)
services.AddValidatorsFromAssembly(assembly);
// Register AutoMapper (scannt Assembly nach Profiles)
services.AddAutoMapper(cfg => {
cfg.LicenseKey = licenseKey;
}, typeof(Common.Mapping.MappingProfile));
return services;
}
}