refactor(application): update workflow queries and exception handling
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using DigitalData.TaskFlow.Application.Options;
|
||||
using FluentValidation;
|
||||
using FluentValidation;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -10,29 +9,30 @@ namespace DigitalData.TaskFlow.Application;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public const string LuckyPennySoftLicenseKeySection = "LuckyPennySoftLicenseKey";
|
||||
|
||||
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var mediatROptions = configuration
|
||||
.GetSection(MediatROptions.SectionName)
|
||||
.Get<MediatROptions>();
|
||||
var lpSoftLicenseKey = configuration[LuckyPennySoftLicenseKeySection];
|
||||
var hasLpSoftLicenseKey = !string.IsNullOrWhiteSpace(lpSoftLicenseKey);
|
||||
|
||||
services
|
||||
.AddOptions<MediatROptions>()
|
||||
.Bind(configuration.GetSection(MediatROptions.SectionName));
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
services.AddMediatR(config =>
|
||||
{
|
||||
config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly);
|
||||
config.RegisterServicesFromAssembly(assembly);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mediatROptions?.LuckyPennySoftLicenseKey))
|
||||
{
|
||||
config.LicenseKey = mediatROptions.LuckyPennySoftLicenseKey;
|
||||
}
|
||||
if (hasLpSoftLicenseKey)
|
||||
config.LicenseKey = lpSoftLicenseKey;
|
||||
});
|
||||
|
||||
services.AddValidatorsFromAssembly(typeof(DependencyInjection).Assembly);
|
||||
services.AddValidatorsFromAssembly(assembly);
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
||||
services.AddAutoMapper(_ => { }, Assembly.GetExecutingAssembly());
|
||||
services.AddAutoMapper(config =>
|
||||
{
|
||||
if (hasLpSoftLicenseKey)
|
||||
config.LicenseKey = lpSoftLicenseKey;
|
||||
}, assembly);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user