private TcpAppCommand RegisterCommandInt(string command, string description, TcpAppServerExecuteDelegate executeCallback, params TcpAppParameter[] parameters) { if (string.IsNullOrEmpty(command)) { throw new ArgumentNullException(nameof(command)); } if (GetCommand(command) != null) { throw new ArgumentException("Failed to register command [" + command + "], already exist!"); } if (command.Contains(" ")) { throw new ArgumentException("Invalid Character in command name, space ' ' is not allowed!"); } TcpAppCommand tCmd = new TcpAppCommand(command, description, executeCallback); foreach (TcpAppParameter a in parameters) { tCmd.AddParameter(a); } for (int x = 0; x < tCmd.Parameters.Count - 1; x++) { if (tCmd.Parameters[x].IsArray) { throw new ArgumentException("Failed to register command [" + command + "], parameter array [" + tCmd.Parameters[x].Name + "] must be last parameter!"); } } Commands.Add(tCmd); return(tCmd); }
/// <summary> /// Clone current object /// </summary> /// <returns></returns> public object Clone() { TcpAppCommand result = new TcpAppCommand(); result.Description = Description; result.Keyword = Keyword; result.ExecuteCallback = ExecuteCallback; result.IsSystemCommand = IsSystemCommand; result.UseMessageQueue = UseMessageQueue; foreach (TcpAppParameter p in Parameters) { result.AddParameter(p); } return(result); }
/// <summary> /// Register Command and Callback /// </summary> /// <param name="command"></param> /// <param name="description"></param> /// <param name="executeCallback"></param> /// <param name="parameters"></param> public void RegisterCommand(string command, string description, TcpAppServerExecuteDelegate executeCallback, params TcpAppParameter[] parameters) { if (GetCommand(command) != null) { throw new ArgumentException("Failed to register command [" + command + "], already exist!"); } if (command.Contains(" ")) { throw new ArgumentException("Invalid Character in command name, space ' ' is not allowed!"); } TcpAppCommand tCmd = new TcpAppCommand(command, description, executeCallback); foreach (TcpAppParameter a in parameters) { tCmd.AddParameter(a); } Commands.Add(tCmd); }