Esempio n. 1
0
        public void ExecuteCommands(IEnumerable <ICommand> commands)
        {
            var arrayCommands     = commands.ToArraySafe();
            var validationResults = ValidateCommands(arrayCommands).ToArraySafe();

            if (validationResults.Any())
            {
                throw new CommandValidationException(validationResults);
            }

            foreach (var command in arrayCommands)
            {
                var handlers = dispatcher.GetHandlers(command);
                foreach (var handler in handlers)
                {
                    var executorInfo = GetExecutorInfo(command, handler);
                    executorInfo.ExecuteHandler(handler, command);
                }
            }
        }