public ICloudBusFactory Build(IConfiguration busConfig)
        {
            AssemblyScanner scanner = new AssemblyScanner();

            // Find all command types
            List <Type> allCommandTypes = busConfig.CommandType.IsAbstract ?
                                          scanner.FindAllTypesExtending(busConfig.CommandType, busConfig.AssembliesToScan).ToList() :
                                          scanner.FindAllTypesImplementing(busConfig.CommandType, busConfig.AssembliesToScan).ToList();

            // Find all event types
            List <Type> allEventTypes = busConfig.EventType.IsAbstract ?
                                        scanner.FindAllTypesExtending(busConfig.EventType, busConfig.AssembliesToScan).ToList() :
                                        scanner.FindAllTypesImplementing(busConfig.EventType, busConfig.AssembliesToScan).ToList();

            AwsEnvironmentBuilder builder = new AwsEnvironmentBuilder(ClientFactory);

            // Build a queue for each command type
            Dictionary <Type, string> commandTypeAndQueueUri = allCommandTypes.ToDictionary(commandType => commandType, commandType => builder.CreateQueueIfDoesntExist(QueueAndTopicNamingConvention.GetQueueNameForCommand(commandType)));

            // Build a topic for each event type
            Dictionary <Type, string> eventTypeAndTopicArns = allEventTypes.ToDictionary(eventType => eventType, eventType => builder.CreateTopicIfDoesntExist(QueueAndTopicNamingConvention.GetTopicNameForEvent(eventType)));

            var awsConfig = new AwsBusConfig(commandTypeAndQueueUri, eventTypeAndTopicArns, QueueAndTopicNamingConvention, ClientFactory);

            if (WorkerConfig == null)
            {
                return(new AwsCloudBusFactory(busConfig, awsConfig));
            }

            // As we have a worker config, create subscriptions for our events
            string queueName = WorkerConfig.SubscriptionQueueNamingConvention.GetWorkerQueueName();
            string eventSubscriptionQueueUrl = builder.CreateQueueIfDoesntExist(queueName);

            foreach (var eventTypeAndTopicArn in eventTypeAndTopicArns)
            {
                builder.SubscribeQueueToTopic(eventSubscriptionQueueUrl, eventTypeAndTopicArn.Value);
            }
            return(new AwsCloudBusFactory(busConfig, awsConfig, WorkerConfig, eventSubscriptionQueueUrl));
        }
 public AwsConfigurator()
 {
     QueueAndTopicNamingConvention = new QueueAndTopicNamingConvention();
 }