Example #1
0
        /// <summary>
        ///	Method to dispatch an event.
        /// </summary>
        /// <typeparam name="TEventType">The type of the event that will be dispatched.</typeparam>
        /// <param name="eventInstance">The event instance that should be pushed to all modules.</param>
        /// <param name="fireSubEvents">Should we fire sub events</param>
        public bool DispatchCommand(string command, Permissions.CommandSender sender, string alias, string[] arguments)
        {
            var isCancelledCommand = false;

            if (_commandRegistry.ContainsKey(command))
            {
                var listeners = _commandRegistry[command];

                foreach (var item in listeners)
                {
                    try
                    {
                        var result = item.onCommand(sender, command, alias, arguments);
                        if (result)
                        {
                            // command is cancelled
                            isCancelledCommand = true;
                            break;
                        }
                    }
                    catch (Exception exception)
                    {
                        var wrappedException = new CommandDispatchingException(command, item.GetType().AssemblyQualifiedName, "An exception occured while processing the command " + command.ToLower(), exception);
                        LogUtility.Exception(wrappedException);
                    }
                }
            }
            else
            {
                // send the sender a message he is sending us unknown commands?
            }


            return(isCancelledCommand);
        }
 public bool DispatchCommand(string command, Permissions.CommandSender sender, string alias, string[] arguments)
 {
     throw new NotImplementedException();
 }