Injecting via primary constructor

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
This commit is contained in:
Whit Waldo 2025-07-12 12:02:21 -05:00
parent fab821bd00
commit 4579828ee1
1 changed files with 7 additions and 13 deletions

View File

@ -22,30 +22,25 @@ using System.Collections.Concurrent;
/// <summary>
/// Defines runtime options for workflows.
/// </summary>
internal sealed class WorkflowLoggingService : IHostedService
internal sealed class WorkflowLoggingService(ILogger<WorkflowLoggingService> logger) : IHostedService
{
private readonly ILogger<WorkflowLoggingService> logger;
private static readonly ConcurrentDictionary<string, byte> registeredWorkflows = new();
private static readonly ConcurrentDictionary<string, byte> registeredActivities = new();
public WorkflowLoggingService(ILogger<WorkflowLoggingService> logger)
{
this.logger = logger;
}
public Task StartAsync(CancellationToken cancellationToken)
{
this.logger.Log(LogLevel.Information, "WorkflowLoggingService started");
logger.Log(LogLevel.Information, "WorkflowLoggingService started");
this.logger.Log(LogLevel.Information, "List of registered workflows");
logger.Log(LogLevel.Information, "List of registered workflows");
foreach (string item in registeredWorkflows.Keys)
{
this.logger.Log(LogLevel.Information, item);
logger.Log(LogLevel.Information, item);
}
this.logger.Log(LogLevel.Information, "List of registered activities:");
logger.Log(LogLevel.Information, "List of registered activities:");
foreach (string item in registeredActivities.Keys)
{
this.logger.Log(LogLevel.Information, item);
logger.Log(LogLevel.Information, item);
}
return Task.CompletedTask;
@ -53,7 +48,7 @@ internal sealed class WorkflowLoggingService : IHostedService
public Task StopAsync(CancellationToken cancellationToken)
{
this.logger.Log(LogLevel.Information, "WorkflowLoggingService stopped");
logger.Log(LogLevel.Information, "WorkflowLoggingService stopped");
return Task.CompletedTask;
}
@ -67,5 +62,4 @@ internal sealed class WorkflowLoggingService : IHostedService
{
registeredActivities.TryAdd(activityName, 0);
}
}