ConnectionHandler <AzureServiceBusConnection> GetConnection( Cache <string, ConnectionHandler <AzureServiceBusConnection> > cache, IAzureServiceBusEndpointAddress address) { var ns = address.Uri.Host; return(cache.Get(ns, _ => { if (_log.IsDebugEnabled) { _log.DebugFormat("Creating RabbitMQ connection: {0}", address.Uri); } ConnectionSettingsBuilder builder = _connectionSettingsBuilders.Get(ns, __ => { if (_log.IsDebugEnabled) { _log.DebugFormat("Using default configurator for connection: {0}", address.Uri); } var configurator = new NamespaceConnectionSettingsConfigurator(ns); return configurator.Configure(); }); IConnectionSettings connectionSettings = builder.Build(); var connection = new AzureServiceBusConnectionImpl(address, connectionSettings.TokenProvider); return new ConnectionHandlerImpl <AzureServiceBusConnection>(connection); })); }
public static World AddWorld(this IServiceCollection services, string eventStoreConnectionString, ConnectionSettingsBuilder connectionSettingsBuilder, Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null) { var eventStoreConnection = EventStoreConnection.Create(eventStoreConnectionString, connectionSettingsBuilder); var connectionSettings = connectionSettingsBuilder.Build(); services.AddSingleton <IConnectionStatusMonitor <IEventStoreConnection>, EventStoreConnectionStatusMonitor>(); services.AddSingleton(eventStoreConnection); services.AddSingleton(connectionSettings); var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration(); getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration); services.AddSingleton <IEventStoreRepositoryConfiguration>(eventStoreRepositoryConfiguration); services.AddTransient <IEventStoreRepository, EventStoreRepository>(); var world = new World(services, true); services.AddSingleton(world); return(world); }