Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public void RegisterPhrase(string phrase, ScriptCommandList command)
 {
     RegisteredCommands.Add(phrase, command);
     _speechRecognizer.RegisterPhrase(phrase);
 }