forked from amkovkov/GranuSightSoftware2
feat: mock run mode
extract IImageCapturerService interface from ImageCapturerService add ImageCapturerMockService as implementation of IImageCapturerService add --mock flag in command line interface and implement its usage
This commit is contained in:
@@ -7,8 +7,7 @@ using Microsoft.Extensions.Logging.Console;
|
||||
|
||||
using GSS2.Core.Logging;
|
||||
using GSS2.Core.Hardware;
|
||||
using GSS2.Core.Analysis.AmineContent.Database.Calibration;
|
||||
using GSS2.Core.Analysis.AmineContent.Database.Results;
|
||||
using GSS2.Core.Analysis.AmineContent.Database;
|
||||
using GSS2.Core.Analysis.AmineContent;
|
||||
|
||||
using ConsoleFormatter = GSS2.Core.Logging.ConsoleFormatter;
|
||||
@@ -128,8 +127,19 @@ public static class DependencyInjectionHelper
|
||||
ServiceLifetime.Singleton
|
||||
);
|
||||
|
||||
public static IServiceCollection AddAmineContentImageCapturerService(this IServiceCollection services) => services
|
||||
.AddSingleton<ImageCapturerService>();
|
||||
public static IServiceCollection AddAmineContentImageCapturerService(this IServiceCollection services, bool mock = false)
|
||||
{
|
||||
if (!mock)
|
||||
return services.AddSingleton<ImageCapturerService>();
|
||||
|
||||
return services.AddSingleton<ImageCapturerMockService>(serviceProvider =>
|
||||
{
|
||||
var logger = serviceProvider.GetService<ILogger<ImageCapturerMockService>>();
|
||||
if (logger is null)
|
||||
throw new Exception("Cannot get logger");
|
||||
return new ImageCapturerMockService("./", logger);
|
||||
});
|
||||
}
|
||||
|
||||
public static IServiceCollection AddAmineContentAnalyzerService(this IServiceCollection services) => services
|
||||
.AddSingleton<AnalyzerService>();
|
||||
|
||||
Reference in New Issue
Block a user