using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using ZB.MOM.WW.Configuration; namespace ZB.MOM.WW.ScadaBridge.KpiHistory; /// /// Composition root for the KPI History component. /// /// /// /// Scaffolds the component: it binds and validates /// . The recorder actor itself is created via /// Props in the Host on the active central node, not registered /// here — mirroring the Notification Outbox singleton wiring. /// /// public static class ServiceCollectionExtensions { /// Configuration section bound to . public const string OptionsSection = "ScadaBridge:KpiHistory"; /// /// Registers the KPI History component services: the validated /// binding. Idempotent re-registration of the /// validator is handled by the shared AddValidatedOptions helper /// (TryAddEnumerable); the options binding itself is call-once per /// . /// /// The service collection to register into. /// Application configuration used to bind . /// The same for chaining. public static IServiceCollection AddKpiHistory(this IServiceCollection services, IConfiguration configuration) { ArgumentNullException.ThrowIfNull(services); ArgumentNullException.ThrowIfNull(configuration); // Binds the "ScadaBridge:KpiHistory" section, registers the validator, // and enables ValidateOnStart in one call — same shape as AddAuditLog. services.AddValidatedOptions(configuration, OptionsSection); return services; } }