This commit renames and refactors all instances of `OutgoingEmail` to `SendingEmail` across the codebase to improve terminology consistency and align with domain language. - Renamed classes, interfaces, and records (e.g., `OutgoingEmailPublisher` → `SendingEmailPublisher`, `OutgoingEmailEvent` → `SendingEmailEvent`). - Updated method signatures, parameters, and return types to use `SendingEmail`. - Adjusted dependency injection registrations to reflect the new naming. - Updated mappings in `EmailMappingProfile` to map `SendEmailCommand` to `SendingEmailEvent`. - Refactored `SendEmailCommand` and its handler to work with `SendingEmailEvent`. - Updated `EmailsController` to use `SendingEmailEvent` in the `SendEmail` action. - Refactored integration tests to test `SendingEmailPublisher` and updated test data accordingly. - Updated log messages, error handling, and comments to reflect the new terminology. - Revised documentation and utility methods to use `SendingEmailEvent`. This refactor ensures consistency, improves readability, and reduces ambiguity in the codebase.
53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using DigitalData.MessagingService.Application.Common.Interfaces;
|
|
using DigitalData.MessagingService.Infrastructure.Queue;
|
|
using DigitalData.MessagingService.Infrastructure.Services;
|
|
using DigitalData.MessagingService.Infrastructure.Services.Background;
|
|
using DigitalData.MessagingService.Publisher;
|
|
using DigitalData.MessagingService.RabbitMQ;
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DigitalData.MessagingService.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// Dependency injection configuration for Infrastructure layer
|
|
/// </summary>
|
|
public static class DependencyInjection
|
|
{
|
|
/// <summary>
|
|
/// Adds Infrastructure layer services to the DI container
|
|
/// </summary>
|
|
public static IServiceCollection AddInfrastructure(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration)
|
|
{
|
|
// --- External Services ---
|
|
// Email Service (using Limilabs Mail.dll - Singleton for use in EmailSenderWorker)
|
|
services.AddSingleton<IEmailService, LimilabsEmailService>();
|
|
|
|
// PDF Processing Service (using DevExpress.Pdf)
|
|
services.AddScoped<IPdfProcessingService, DevExpressPdfProcessingService>();
|
|
|
|
// Encryption Service (using Data Protection API - Singleton, thread-safe)
|
|
services.AddSingleton<IEncryptionService, DataProtectionEncryptionService>();
|
|
|
|
// --- Email Queue (RabbitMQ) ---
|
|
services.AddSingleton<SendingEmailConsumer>();
|
|
services.AddMessagingServicePublisher();
|
|
|
|
// --- RabbitMQ Configuration ---
|
|
services.AddRabbitMqConnectionFactory(configuration);
|
|
|
|
// --- Data Protection (for encryption) ---
|
|
services.AddDataProtection()
|
|
.PersistKeysToFileSystem(new DirectoryInfo(@"C:\ProgramData\EmailService\Keys"))
|
|
.SetApplicationName("MessagingService");
|
|
|
|
// Register Background Workers
|
|
services.AddHostedService<AsyncInitWorker>();
|
|
|
|
return services;
|
|
}
|
|
}
|