public void GetCommand(out List <KeyValuePair <IModule, ICommand> > cmds, xtype xtype) { if (!commands.ContainsKey(xtype)) { //Command does not exist in any module cmds = null; return; } List <KeyValuePair <IModule, ICommand> > cmd = commands[xtype]; List <KeyValuePair <IModule, ICommand> > allowed = new List <KeyValuePair <IModule, ICommand> >(); if (cmd.Count > 0) { foreach (KeyValuePair <IModule, ICommand> p in cmd) { if (!this.disabledModules.Contains(p.Key)) { allowed.Add(p); } } //Multiple options and no module specified cmds = allowed; return; } //Match command with module KeyValuePair <IModule, ICommand> r = commands[xtype][0]; if (!this.disabledModules.Contains(r.Key)) { allowed.Add(r); } cmds = allowed; }
public Command(string name, Action <ICommandContext> action, string desc = "Manages a scheduled event.") { this.name = xtype.Register(name); this.action = action; this.desc = desc; }