public IStartableBus CreateBus() { if (this.ServiceLocator == null) { throw new InvalidConfigurationException("A ServiceLocator instance must be specified."); } var messageTypes = MessageTypeConventions.ScanAssembliesForMessageTypes(AssembliesToScan); var messageMapper = new MessageMapper(MessageTypeConventions); messageMapper.Initialize(messageTypes); var messageHandlers = new MessageHandlerCollection(MessageTypeConventions); messageHandlers.ScanAssembliesAndInitialize(AssembliesToScan); var staticRoutes = new Dictionary <Type, string>(); foreach (var mapping in MessageEndpointMappings.OrderByDescending(m => m)) { mapping.Configure((messageType, endpoint) => { if (!MessageTypeConventions.IsMessageType(messageType)) { return; } staticRoutes[messageType] = endpoint; logger.Debug("Mapping message type [{0}] to endpoint [{1}]", messageType.FullName, endpoint); }); } return(new LightRailServiceBus(this, messageMapper, messageHandlers, staticRoutes)); }