Update DI packages and enhance logging support

Updated `Microsoft.Extensions.DependencyInjection` to version 10.0.10 and added `Microsoft.Extensions.Logging` as a new dependency. Updated `EmailSender.cs` to include logging support by registering logging services in the DI container. Modified XML documentation to reflect the new `ConnectRabbitMq(Action<RabbitMqConfiguration>, OnReconnect)` method signature. Updated exception documentation to align with the new method signature.
This commit is contained in:
2026-07-29 11:01:45 +02:00
parent 6183ea613f
commit 5d9197f54a
2 changed files with 8 additions and 5 deletions

View File

@@ -21,8 +21,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.10" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.10" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.10" />
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
</ItemGroup>

View File

@@ -2,6 +2,7 @@
using DigitalData.MessagingService.Publisher.Abstraction;
using DigitalData.MessagingService.RabbitMQ;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
namespace DigitalData.MessagingService.Client.DependencyInjection;
@@ -13,14 +14,14 @@ namespace DigitalData.MessagingService.Client.DependencyInjection;
/// <remarks>
/// This class manages its own internal <see cref="IServiceProvider"/> using a
/// <see cref="Lazy{T}"/> pattern so the DI container is only built once,
/// on the first call to <see cref="ConnectRabbitMq"/>.
/// on the first call to <see cref="ConnectRabbitMq(Action{RabbitMqConfiguration}, OnReconnect)"/>.
/// </remarks>
public static class EmailSender
{
/// <summary>
/// Internal event used to accumulate service registrations before the
/// <see cref="IServiceProvider"/> is built. Handlers are added by
/// <see cref="ConnectRabbitMq"/> and invoked exactly once during
/// <see cref="ConnectRabbitMq(Action{RabbitMqConfiguration}, OnReconnect)"/> and invoked exactly once during
/// lazy initialization.
/// </summary>
private static event Action<IServiceCollection> ConfigureServices = delegate { };
@@ -33,6 +34,7 @@ public static class EmailSender
private static readonly Lazy<IServiceProvider> LazyProvider = new(() =>
{
var services = new ServiceCollection();
services.AddLogging();
ConfigureServices?.Invoke(services);
return services.BuildServiceProvider();
});
@@ -42,7 +44,7 @@ public static class EmailSender
/// and the internal <see cref="IServiceProvider"/> has been initialized.
/// </summary>
/// <value>
/// <see langword="true"/> if <see cref="ConnectRabbitMq"/> has been called
/// <see langword="true"/> if <see cref="ConnectRabbitMq(Action{RabbitMqConfiguration}, OnReconnect)"/> has been called
/// and the provider is built; otherwise <see langword="false"/>.
/// </value>
public static bool IsConnected => LazyProvider.IsValueCreated;
@@ -110,7 +112,7 @@ public static class EmailSender
/// </summary>
/// <param name="email">The outgoing email event to enqueue.</param>
/// <exception cref="InvalidOperationException">
/// Thrown when <see cref="ConnectRabbitMq"/> has not been called prior to sending.
/// Thrown when <see cref="ConnectRabbitMq(Action{RabbitMqConfiguration}, OnReconnect)"/> has not been called prior to sending.
/// </exception>
/// <remarks>
/// This method resolves <see cref="IOutgoingEmailPublisher"/> from the internal