private ConnectionTarget(ServerLocation server, DestinationPort port, List <DestinationPort> portsToReconnect, IPAddress currentManualDns) { Server = server; Port = port; CurrentManualDns = currentManualDns; if (portsToReconnect != null && portsToReconnect.Count > 0) { if (!portsToReconnect.Contains(port)) { throw new ArgumentOutOfRangeException(nameof(portsToReconnect), "Preffered ports list does not caontain Port which is defined as first"); } PortsToReconnect.AddRange(portsToReconnect); } }
public DestinationPort ChangeToNextPort() { if (PortsToReconnect.Count <= 0) { return(Port); } int idx = PortsToReconnect.IndexOf(Port); int newIdx = idx + 1; if (newIdx >= PortsToReconnect.Count) { newIdx = 0; } Port = PortsToReconnect[newIdx]; return(Port); }