big refactoring. get rid of static properties and coupled architecture. prepare system for integration tests

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-11-17 13:14:05 +02:00
parent 22529c26ec
commit e7ea5a8ded
38 changed files with 808 additions and 157 deletions
@@ -0,0 +1,45 @@
using Azaion.Common.Database;
using Azaion.Common.DTO;
using Azaion.Common.DTO.Config;
using Azaion.Common.Services;
using Azaion.Common.Services.Inference;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace Azaion.Common.Infrastructure;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddAzaionInfrastructure(this IServiceCollection services)
{
services.AddSingleton<IFileSystem, PhysicalFileSystem>();
services.AddSingleton<IProcessLauncher, ProcessLauncher>();
services.AddSingleton<IAnnotationPathResolver>(sp =>
new AnnotationPathResolver(sp.GetRequiredService<IOptions<DirectoriesConfig>>().Value));
services.AddSingleton<IDetectionClassProvider, DetectionClassProvider>();
services.AddSingleton<IAnnotationRepository, AnnotationRepository>();
return services;
}
public static IServiceCollection AddAzaionConfiguration(this IServiceCollection services)
{
services.AddSingleton<IConfigurationStore>(sp =>
new FileConfigurationStore(Constants.CONFIG_PATH, sp.GetRequiredService<IFileSystem>()));
services.AddSingleton<IConfigUpdater, ConfigUpdater>();
return services;
}
public static IServiceCollection AddAzaionServices(this IServiceCollection services)
{
services.AddSingleton<IDbFactory, DbFactory>();
services.AddSingleton<FailsafeAnnotationsProducer>();
services.AddSingleton<IAnnotationService, AnnotationService>();
services.AddSingleton<IGalleryService, GalleryService>();
services.AddSingleton<IInferenceService, InferenceService>();
return services;
}
}