private static bool TryParseCreateServerCommand(string[] arguments, out ICommand command) { command = null; if (arguments.Length != 4) { return(false); } string serverId = arguments[0]; string URL = arguments[1]; if (!int.TryParse(arguments[2], out int minDelay)) { return(false); } if (!int.TryParse(arguments[3], out int maxDelay)) { return(false); } if (!HttpURLs.TryParseHostAndPort(URL, out string host, out int port)) { return(false); } command = new CreateServerCommand { ServerId = serverId, Host = host, Port = port, MinDelay = minDelay, MaxDelay = maxDelay }; return(true); }
private static bool TryParseCreateClientCommand(string[] arguments, out ICommand command) { command = null; if (arguments.Length != 3) { return(false); } string username = arguments[0]; string URL = arguments[1]; string scriptFile = arguments[2]; if (!HttpURLs.TryParseHostAndPort(URL, out string host, out int port)) { return(false); } command = new CreateClientCommand { Username = username, Host = host, Port = port, ScriptFile = scriptFile }; return(true); }