using FluentValidation; using Microsoft.Extensions.DependencyInjection; namespace DocumentOperator.Application; /// /// Dependency Injection configuration for Application Layer /// public static class DependencyInjection { /// /// Registers Application Layer services (MediatR, FluentValidation, AutoMapper, Behaviors) /// public static IServiceCollection AddApplication(this IServiceCollection services) { var assembly = typeof(DependencyInjection).Assembly; // Register MediatR (scannt Assembly nach Handlers) services.AddMediatR(config => { 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 => { }, typeof(Common.Mapping.MappingProfile)); return services; } }