using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using ScadaLink.Commons.Interfaces.Transport; using ScadaLink.Transport.Encryption; using ScadaLink.Transport.Export; using ScadaLink.Transport.Import; using ScadaLink.Transport.Serialization; namespace ScadaLink.Transport; public static class ServiceCollectionExtensions { public const string OptionsSection = "ScadaLink:Transport"; public static IServiceCollection AddTransport(this IServiceCollection services) { ArgumentNullException.ThrowIfNull(services); services.AddOptions().BindConfiguration(OptionsSection); services.TryAddSingleton(TimeProvider.System); // Pipeline building blocks: stateless services live as singletons; the // resolver and exporter are scoped because they reach into per-request // repository scopes and the scoped DbContext. services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddScoped(); services.AddScoped(); services.AddSingleton(); // Remaining concrete services added in later tasks. return services; } }