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, 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);
return services;
}
}