public void SendProtocol(IProtocol protocol, IPEndPoint from, string to) { if (protocol.Action != ActionType.Response) { return; } var bytes = protocol.GetBytes(); AbstractServer server = protocol.Header switch { HeaderType.Discover => _multicastBroadcastServers.First(multicastServer => multicastServer.EndPoint.Equals(from)), HeaderType.Time => _tcpServers.First(multithreadingServer => multithreadingServer.EndPoint.Equals(from)), _ => throw new ArgumentOutOfRangeException() }; server.Send(bytes, to); }