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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.12" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.12" />
|
||||
<PackageReference Include="AutoMapper" Version="16.2.0" />
|
||||
<PackageReference Include="FluentValidation" Version="12.1.1" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.1" />
|
||||
<PackageReference Include="MediatR" Version="14.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="11.0.0-rc.1.26425.128" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="11.0.0-rc.1.26425.128" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="11.0.0-rc.1.26425.128" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace DigitalData.TaskFlow.Application.Options;
|
||||
|
||||
public sealed class MediatROptions
|
||||
{
|
||||
public const string SectionName = "MediatR";
|
||||
|
||||
public string? LuckyPennySoftLicenseKey { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user