Add MediatR, FluentValidation, AutoMapper, and EF Core

Updated application and infrastructure layers to include MediatR, FluentValidation, AutoMapper, and Entity Framework Core.

- Added new dependencies to `DigitalData.TaskFlow.Application.csproj` and `DigitalData.TaskFlow.Infrastructure.csproj` for MediatR, FluentValidation, AutoMapper, and EF Core.
- Configured MediatR with options and license key support.
- Registered validators and AutoMapper profiles in the application layer.
- Introduced `MediatROptions` and `SwaggerOptions` for configuration.
- Updated `appsettings.json` with connection strings and configuration sections for MediatR and Swagger.
- Replaced placeholder comments in `DependencyInjection` classes with actual service registrations.
- Upgraded `Swashbuckle.AspNetCore` and added `FluentValidation.AspNetCore` for API validation.
This commit is contained in:
2026-10-09 16:29:58 +02:00
parent ee107d74c4
commit b0fd71e193
8 changed files with 70 additions and 11 deletions

View File

@@ -1,5 +1,9 @@
using Microsoft.Extensions.Configuration;
using DigitalData.TaskFlow.Application.Options;
using FluentValidation;
using MediatR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace DigitalData.TaskFlow.Application;
@@ -7,8 +11,27 @@ public static class DependencyInjection
{
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration)
{
// Register application services here
// Example: services.AddSingleton<IMyService, MyService>();
var mediatROptions = configuration
.GetSection(MediatROptions.SectionName)
.Get<MediatROptions>();
services
.AddOptions<MediatROptions>()
.Bind(configuration.GetSection(MediatROptions.SectionName));
services.AddMediatR(config =>
{
config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly);
if (!string.IsNullOrWhiteSpace(mediatROptions?.LuckyPennySoftLicenseKey))
{
config.LicenseKey = mediatROptions.LuckyPennySoftLicenseKey;
}
});
services.AddValidatorsFromAssembly(typeof(DependencyInjection).Assembly);
services.AddAutoMapper(_ => { }, Assembly.GetExecutingAssembly());
return services;
}
}