Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves commands for a particular group
        /// </summary>
        /// <param name="group">Group id</param>
        /// <returns>Map of command id to command object</returns>
        public IDictionary <int, ICommand> GetGroupCommands(Guid group)
        {
            Dictionary <int, ICommand> groupCommands = null;

            if (CommandMap.TryGetValue(group, out groupCommands))
            {
                return(groupCommands);
            }

            return(new Dictionary <int, ICommand>());
        }
Ejemplo n.º 2
0
        public ICommand Find(Guid group, int id)
        {
            Dictionary <int, ICommand> idToCommandMap = null;

            if (!CommandMap.TryGetValue(group, out idToCommandMap))
            {
                return(null);
            }

            ICommand cmd = null;

            idToCommandMap.TryGetValue(id, out cmd);

            return(cmd);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds command to the controller command table
        /// </summary>
        /// <param name="command">Command object</param>
        public void AddCommand(ICommand command)
        {
            if (command != null)
            {
                foreach (CommandId commandId in command.CommandIds)
                {
                    Dictionary <int, ICommand> idToCommandMap = null;

                    if (!CommandMap.TryGetValue(commandId.Group, out idToCommandMap))
                    {
                        idToCommandMap = new Dictionary <int, ICommand>();
                        CommandMap.Add(commandId.Group, idToCommandMap);
                    }

                    if (!idToCommandMap.ContainsKey(commandId.Id))
                    {
                        idToCommandMap.Add(commandId.Id, command);
                    }
                }
            }
        }