using System.Reflection; using FluentValidation; using Heimdall.Application.Behaviors; using MediatR; using Microsoft.Extensions.DependencyInjection; namespace Heimdall.Application; public static class DependencyInjection { public static IServiceCollection AddApplication(this IServiceCollection services) { var assembly = typeof(DependencyInjection).Assembly; // MediatR — register all command/query handlers from this assembly services.AddMediatR(cfg => { cfg.RegisterServicesFromAssembly(assembly); // Pipeline behaviors (executed in registration order) cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); }); // AutoMapper — scan assembly for profiles (including MappingProfile) services.AddAutoMapper(assembly); // FluentValidation — auto-register all validators services.AddValidatorsFromAssembly(assembly); return services; } }