using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer; /// /// DI registration extensions for the Data Connection Layer. /// public static class ServiceCollectionExtensions { /// Registers Data Connection Layer options and core services. /// The DI service collection to register into. /// The same instance for chaining. public static IServiceCollection AddDataConnectionLayer(this IServiceCollection services) { // Canonical section is ScadaBridge:DataConnection — the section every real // appsettings actually writes (arch-review 08 round 2 NF8). The Host used to // supply the real values via a duplicate Configure<> binding; that duplicate is // gone, so AddDataConnectionLayer must bind the canonical section itself. services.AddOptions() .BindConfiguration("ScadaBridge:DataConnection") .ValidateOnStart(); services.TryAddEnumerable( ServiceDescriptor.Singleton, DataConnectionOptionsValidator>()); // Validate identities before the first connection attempts to register with a server. services.AddOptions() .BindConfiguration("ScadaBridge:OpcUa") .ValidateOnStart(); services.TryAddEnumerable( ServiceDescriptor.Singleton, OpcUaGlobalOptionsValidator>()); services.AddOptions() .BindConfiguration("ScadaBridge:MxGateway") .ValidateOnStart(); services.TryAddEnumerable( ServiceDescriptor.Singleton, MxGatewayGlobalOptionsValidator>()); // Register the factory for protocol extensibility services.AddSingleton(); return services; } /// Placeholder for actor registration; Data Connection Layer actors are created inside the ActorSystem. /// The DI service collection. /// The same instance for chaining. public static IServiceCollection AddDataConnectionLayerActors(this IServiceCollection services) { // Actor registration happens in AkkaHostedService or SiteCommunicationActor setup. // DataConnectionManagerActor and DataConnectionActor instances are created by the actor system. return services; } }