public static bool TryParse(string message, out DccCommand command, out string parameter) { string commandString = message; int position = message.IndexOf(' '); if (position >= 0) { parameter = commandString.Substring(position + 1); commandString = commandString.Remove(position).ToUpper(); } else { parameter = string.Empty; } var matches = dccCommands .Where((x) => x.Value == commandString) .Select((x) => x.Key); command = matches.FirstOrDefault(); return(matches.Any()); }
public static string ToCommandString(this DccCommand command) { return(dccCommands[command]); }