예제 #1
0
        /// <summary>
        /// Registers a console command to the console command list.
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="description"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static bool AddCommnd(List<string> alias, string description, ConsoleCommandDelegate callback)
        {
            // Validate the parameters..
            if (alias.Count == 0 || string.IsNullOrEmpty(description) || callback == null)
                return false;

            // Ensure no other command has any alias defined..
            if (ConsoleCommands.Commands.Any(c => alias.Any(c.HasAlias)))
                return false;

            // Add the new command..
            var cmd = new ConsoleCommand(alias, callback) { Description = description };
            ConsoleCommands.Commands.Add(cmd);
            return true;
        }
예제 #2
0
        /// <summary>
        /// Registers a console command to the console command list.
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="description"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static bool AddCommnd(List <string> alias, string description, ConsoleCommandDelegate callback)
        {
            // Validate the parameters..
            if (alias.Count == 0 || string.IsNullOrEmpty(description) || callback == null)
            {
                return(false);
            }

            // Ensure no other command has any alias defined..
            if (ConsoleCommands.Commands.Any(c => alias.Any(c.HasAlias)))
            {
                return(false);
            }

            // Add the new command..
            var cmd = new ConsoleCommand(alias, callback)
            {
                Description = description
            };

            ConsoleCommands.Commands.Add(cmd);
            return(true);
        }