using FluentValidation;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
using TakeoutSaaS.Application.App.Common.Behaviors;
using TakeoutSaaS.Application.App.Personal.Services;
using TakeoutSaaS.Application.App.Personal.Validators;
namespace TakeoutSaaS.Application.App.Extensions;
///
/// 业务应用层服务注册。
///
public static class AppApplicationServiceCollectionExtensions
{
///
/// 注册业务应用层(MediatR 处理器等)。
///
/// 服务集合。
/// 服务集合。
public static IServiceCollection AddAppApplication(this IServiceCollection services)
{
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
// 1. 注册个人中心基础服务
services.AddScoped();
services.AddSingleton();
services.AddSingleton();
services.AddScoped();
services.AddScoped();
return services;
}
}