Ejemplo n.º 1
0
        public IMessageProcessor Create(IUnitOfWork unitOfWork, IMessageMapper mappingEngine,
		                                CommandEngineConfiguration configuration)
        {
            return new MessageProcessor(mappingEngine,
                                        new CommandInvoker(new ValidationEngine(new ValidationRuleFactory()),
                                                           new CommandFactory()), unitOfWork, configuration);
        }
Ejemplo n.º 2
0
 public MessageProcessor(IMessageMapper mappingEngine, ICommandInvoker commandInvoker, IUnitOfWork unitOfWork,
     CommandEngineConfiguration configuration
     )
 {
     _mappingEngine = mappingEngine;
     _commandInvoker = commandInvoker;
     _unitOfWork = unitOfWork;
     _configuration = configuration;
 }
Ejemplo n.º 3
0
 public void Initialize(Assembly assembly, IMessageMapper messageMapper)
 {
     if (_mappingEngine == null)
     {
         lock (_lock)
         {
             if (_configuration == null)
             {
                 Configuration = new CommandEngineConfiguration();
                 Configuration.Initialize(assembly);
                 _mappingEngine = messageMapper;
             }
         }
     }
 }
		private static void ConventionConfiguration(CommandEngineConfiguration configuration, Type inputType, Type messageType)
		{
			var inputTypes = inputType.Assembly.GetTypes()
							.Where(t=>TypeIsAnInputModel(t, inputType)).ToArray();

			var messageTypes = messageType.Assembly.GetTypes()
					.Where(t =>TypeIsACommandMessage(t, messageType));
			                                 
			foreach (Type input in inputTypes)
			{
				if (!configuration.MessageConfigurations.ContainsKey(input))
				{
					Type actualMessageType = messageTypes.FirstOrDefault(type => InputToCommandMessage(type, input));
					if (actualMessageType!=null)
					{
						configuration.MessageConfigurations.Add(input, new ConventionMessageConfiguration(actualMessageType));
					}
				}
			}
		}