Du hast auf den Branch log-test-branch 2026-04-12 20:57:35 +00:00 gepusht
Neuer Pull-Request
Du hast auf den Branch anon-test2 2026-04-12 20:50:35 +00:00 gepusht
Neuer Pull-Request
Dateien
Soft-LTS/Configuration/PrinterConfig.cs
2026-04-12 17:22:31 +02:00

40 Zeilen
1.4 KiB
C#

namespace PrinterMonitor.Configuration;
public class PrinterConfig
{
private static readonly HashSet<string> ValidTypes = new(StringComparer.OrdinalIgnoreCase)
{ "CabSquix", "Zebra", "Honeywell", "Simulation" };
public string Name { get; set; } = "";
public string Type { get; set; } = "CabSquix"; // "CabSquix", "Zebra", "Honeywell" oder "Simulation"
public string Host { get; set; } = "";
public int Port { get; set; } // Drucker-Kommunikationsport (bei Simulation ignoriert)
public bool Enabled { get; set; } = true;
/// <summary>
/// Prüft die Konfiguration und gibt eine Liste von Fehlern zurück (leer = gültig).
/// </summary>
public List<string> Validate()
{
var errors = new List<string>();
if (string.IsNullOrWhiteSpace(Name))
errors.Add("Name darf nicht leer sein");
if (!ValidTypes.Contains(Type ?? ""))
errors.Add($"Ungültiger Druckertyp '{Type}'");
var isSimulation = string.Equals(Type, "Simulation", StringComparison.OrdinalIgnoreCase);
if (!isSimulation)
{
if (string.IsNullOrWhiteSpace(Host))
errors.Add($"'{Name}': Host darf nicht leer sein");
if (Port < 1 || Port > 65535)
errors.Add($"'{Name}': Port muss zwischen 1 und 65535 liegen (ist {Port})");
}
return errors;
}
}