/// <summary> /// Register commands of service type 1. /// </summary> public void RegisterCommand <T>() where T : class, ICommand { ICommand command = assemblyCommands.FirstOrDefault(c => c is T); if (command == null) { throw new Exception(string.Format("Could not find command of type '{0}'.", typeof(T))); } RegisteredCommands.Add(command); }
private void Command_OnCommandChange(object sender, CommandChangeEventArgs e) { if (e.IsRemoval) { if (RegisteredCommands.ContainsKey(e.Key)) { RegisteredCommands.Remove(e.Key); } } else { RegisteredCommands.Add(e.Key, e.IsMasterJob); } }
public static void Register(string commandName, params Trigger[] commandTriggers) { if (string.IsNullOrEmpty(commandName)) { throw new ArgumentNullException("commandName"); } if (commandTriggers == null || commandTriggers.Length == 0) { throw new UnableToRegisterCommandWithoutTriggers(commandName); } if (RegisteredCommands.ContainsKey(commandName)) { RegisteredCommands[commandName] = commandTriggers; } else { RegisteredCommands.Add(commandName, commandTriggers); } }
public void RegisterPhrase(string phrase, ScriptCommandList command) { RegisteredCommands.Add(phrase, command); _speechRecognizer.RegisterPhrase(phrase); }