Example #1
0
        /// <summary>
        /// Connects the Command Source to the Command.
        /// </summary>
        /// <param name="commandSource">Command source to connect to the command.</param>
        /// <param name="command">Reference to the command.</param>
        public static void RegisterCommand(ICommandSource commandSource, ICommand command)
        {
            if (commandSource == null)
                throw new NullReferenceException("commandSource cannot be null");
            if (command == null)
                throw new NullReferenceException("command cannot be null");

            ArrayList subscribers = null;
            if (_CommandBindings.Contains(command))
            {
                subscribers = (ArrayList)_CommandBindings[command];
                if (!subscribers.Contains(commandSource))
                    subscribers.Add(commandSource);
            }
            else
            {
                subscribers = new ArrayList();
                subscribers.Add(commandSource);
                _CommandBindings.Add(command, subscribers);
            }
            command.CommandSourceRegistered(commandSource);
        }