Ejemplo n.º 1
0
        /// <summary>
        /// Gets the command with the specified command identifier.
        /// </summary>
        /// <param name="commandIdentifier">The command identifier of the command to get.</param>
        /// <returns>The command, or null if a command with the specified command identifier cannot be found.</returns>
        public Command Get(string commandIdentifier)
        {
            CommandInstanceManager commandInstanceManager = (CommandInstanceManager)commandTable[commandIdentifier];
            Command command = (commandInstanceManager == null) ? null : commandInstanceManager.ActiveCommandInstance;

            return(command);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a command instance.
        /// </summary>
        /// <param name="commandList">The Command instance to remove.</param>
        private void RemoveCommand(Command command)
        {
            commandShortcutTableIsStale = true;
            CommandInstanceManager commandInstanceManager = (CommandInstanceManager)commandTable[command.Identifier];

            if (commandInstanceManager != null)
            {
                commandInstanceManager.Remove(command);
                if (commandInstanceManager.IsEmpty)
                {
                    commandTable.Remove(command.Identifier);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a command instance.
        /// </summary>
        /// <param name="command">The Command instance to add.</param>
        private void AddCommand(Command command)
        {
            commandShortcutTableIsStale = true;
            CommandInstanceManager commandInstanceManager = (CommandInstanceManager)commandTable[command.Identifier];

            if (commandInstanceManager == null)
            {
                commandTable[command.Identifier] = new CommandInstanceManager(command);
            }
            else
            {
                commandInstanceManager.Add(command);
            }
        }
Ejemplo n.º 4
0
        public Command Get(CommandId commandIdentifier)
        {
            string str;

            if (!commandIdToString.TryGetValue(commandIdentifier, out str))
            {
                str = commandIdentifier.ToString();
                commandIdToString.Add(commandIdentifier, str);
            }
            CommandInstanceManager commandInstanceManager = (CommandInstanceManager)commandTable[str];
            Command command = (commandInstanceManager == null) ? null : commandInstanceManager.ActiveCommandInstance;

            return(command);
        }