diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs index 56f826591..da5856848 100644 --- a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs +++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublisherConfiguration.cs @@ -26,8 +26,32 @@ namespace Tango.Telemetry public void Validate() { - if (!MachineID.IsNotNullOrEmpty()) throw new ArgumentNullException($"{nameof(MachineID)} is not set."); - if (!Environment.IsNotNullOrEmpty()) throw new ArgumentNullException($"{nameof(Environment)} is not set."); + if (!MachineID.IsNotNullOrEmpty()) + throw new ArgumentNullException(nameof(MachineID), "MachineID is not set or empty."); + + if (!Environment.IsNotNullOrEmpty()) + throw new ArgumentNullException(nameof(Environment), "Environment is not set or empty."); + + if (!Enum.IsDefined(typeof(MachineTypes), MachineType)) + throw new ArgumentOutOfRangeException(nameof(MachineType), "MachineType is not a valid enum value."); + + if (DiagnosticsSamplingInterval.TotalSeconds < 1) + throw new ArgumentOutOfRangeException(nameof(DiagnosticsSamplingInterval), "DiagnosticsSamplingInterval must be at least 1 second."); + + if (PendingStorageCheckInterval.TotalSeconds < 5) + throw new ArgumentOutOfRangeException(nameof(PendingStorageCheckInterval), "PendingStorageCheckInterval must be at least 5 seconds."); + + if (TelemetryDestinations == null || TelemetryDestinations.Count == 0) + throw new InvalidOperationException("At least one telemetry destination must be provided."); + + foreach (var destination in TelemetryDestinations) + { + if (destination == null) + throw new InvalidOperationException("Telemetry destination list contains a null entry."); + + if (destination.SupportedSources == null || destination.SupportedSources.Count == 0) + throw new InvalidOperationException($"Telemetry destination '{destination.Name}' has no supported sources defined."); + } } } } |
