예제 #1
0
        public ExecutionResult Process(object message, Type messageType)
        {
            var totalResult = new ExecutionResult();
            IMessageConfiguration messageConfiguration = _configuration.GetMessageConfiguration(messageType);

            IEnumerable <ICommandConfiguration> commandConfigurations = messageConfiguration.GetApplicableCommands(message);

            foreach (ICommandConfiguration commandConfiguration in commandConfigurations)
            {
                object commandMessage =
                    _mappingEngine.MapUiMessageToCommandMessage(message, messageType, commandConfiguration.CommandMessageType);

                commandConfiguration.Initialize(commandMessage, totalResult);

                ExecutionResult results = _commandInvoker.Process(commandMessage, commandConfiguration);
                totalResult.MergeWith(results);

                if (!totalResult.Successful)
                {
                    _unitOfWork.Invalidate();
                    break;
                }
            }

            return(totalResult);
        }