public static bool TryGetProtocolById(string id, out WellKnownProtocol protocol) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(id)); } return(protocolsById.TryGetValue(id, out protocol)); }
private static void Define(string id, int port) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(id)); } protocolsById[id] = new WellKnownProtocol(id, port); protocolsByPort[port] = new WellKnownProtocol(id, port); }
public static bool TryGetProtocolByPort(int port, out WellKnownProtocol protocol) { return(protocolsByPort.TryGetValue(port, out protocol)); }