示例#1
0
        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);
        }
示例#2
0
        /// <summary>
        /// Register new command.
        /// </summary>
        /// <param name="command">Command keyword, single word.</param>
        /// <param name="description">Short description of command.</param>
        /// <param name="executeCallback">Command execution callback.</param>
        /// <returns></returns>
        public TcpAppCommand RegisterCommand(string command, string description, TcpAppServerExecuteDelegate executeCallback)
        {
            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);

            Commands.Add(tCmd);
            return(tCmd);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="keyword">Command unique keyword</param>
 /// <param name="description">Description / Short Help.</param>
 /// <param name="executeCallback">Callback function</param>
 public TcpAppCommand(string keyword, string description, TcpAppServerExecuteDelegate executeCallback)
 {
     Keyword         = keyword;
     Description     = description;
     ExecuteCallback = executeCallback;
 }
示例#4
0
 /// <summary>
 /// Register new command which execute using command queue
 /// </summary>
 /// <param name="command"></param>
 /// <param name="description"></param>
 /// <param name="executeCallback"></param>
 /// <param name="parameters"></param>
 public void RegisterQueuedCommand(string command, string description, TcpAppServerExecuteDelegate executeCallback, params TcpAppParameter[] parameters)
 {
     RegisterCommandInt(command, description, executeCallback, parameters).UseMessageQueue = true;
 }
 /// <summary>
 /// Register System Command for derrived class.
 /// </summary>
 /// <param name="command"></param>
 /// <param name="description"></param>
 /// <param name="executeCallback"></param>
 /// <param name="parameters"></param>
 protected void RegisterSystemCommand(string command, string description, TcpAppServerExecuteDelegate executeCallback, params TcpAppParameter[] parameters)
 {
     RegisterCommandInt(command, description, executeCallback, parameters).IsSystemCommand = true;
 }