Skip to content

Commit 92d63ac

Browse files
committed
refactor: add ClockModule in Fitnet common clock
A new file named ClockModule.cs has been added within the Fitnet common clock namespace and a method called AddClock is established. The method, taking the IServiceCollection services as a parameter, returns the Singleton of the TimeProvider System. In addition, the TimeProvider instance injection in Program.cs has been replaced by AddClock().
1 parent 0161eef commit 92d63ac

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace EvolutionaryArchitecture.Fitnet.Common.Clock;
2+
3+
internal static class ClockModule
4+
{
5+
internal static IServiceCollection AddClock(this IServiceCollection services) =>
6+
services.AddSingleton(TimeProvider.System);
7+
}

Chapter-1-initial-architecture/Src/Fitnet/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using EvolutionaryArchitecture.Fitnet.Common.Clock;
12
using EvolutionaryArchitecture.Fitnet.Common.ErrorHandling;
23
using EvolutionaryArchitecture.Fitnet.Common.Events.EventBus;
34
using EvolutionaryArchitecture.Fitnet.Common.Validation.Requests;
@@ -13,7 +14,7 @@
1314
builder.Services.AddSwaggerGen();
1415
builder.Services.AddEventBus();
1516
builder.Services.AddRequestsValidations();
16-
builder.Services.AddSingleton(TimeProvider.System);
17+
builder.Services.AddClock();
1718

1819
builder.Services.AddPasses(builder.Configuration);
1920
builder.Services.AddContracts(builder.Configuration);

0 commit comments

Comments
 (0)