namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Models; /// /// Settings for establishing an OPC UA client connection. /// public sealed class ConnectionSettings { /// /// The primary OPC UA endpoint URL. /// public string EndpointUrl { get; set; } = string.Empty; /// /// Optional failover endpoint URLs for redundancy. /// public string[]? FailoverUrls { get; set; } /// /// Optional username for authentication. /// public string? Username { get; set; } /// /// Optional password for authentication. /// public string? Password { get; set; } /// /// Transport security mode. Defaults to . /// public SecurityMode SecurityMode { get; set; } = SecurityMode.None; /// /// Session timeout in seconds. Defaults to 60. /// public int SessionTimeoutSeconds { get; set; } = 60; /// /// Whether to automatically accept untrusted server certificates. Defaults to true. /// public bool AutoAcceptCertificates { get; set; } = true; /// /// Path to the certificate store. Defaults to a subdirectory under LocalApplicationData. /// public string CertificateStorePath { get; set; } = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LmxOpcUaClient", "pki"); /// /// Validates the settings and throws if any required values are missing or invalid. /// /// Thrown when settings are invalid. public void Validate() { if (string.IsNullOrWhiteSpace(EndpointUrl)) throw new ArgumentException("EndpointUrl must not be null or empty.", nameof(EndpointUrl)); if (SessionTimeoutSeconds <= 0) throw new ArgumentException("SessionTimeoutSeconds must be greater than zero.", nameof(SessionTimeoutSeconds)); if (SessionTimeoutSeconds > 3600) throw new ArgumentException("SessionTimeoutSeconds must not exceed 3600.", nameof(SessionTimeoutSeconds)); } }