public static ProjectionConfiguration Configuration(IConnectionConfigurationProvider provider) { Guard.AgainstNull(provider, nameof(provider)); var section = ConfigurationSectionProvider.Open <ProjectionSection>("shuttle", "projection"); var configuration = new ProjectionConfiguration(); var eventStoreConnectionStringName = "EventStore"; var eventProjectionConnectionStringName = "EventStore"; if (section != null) { eventStoreConnectionStringName = section.EventStoreConnectionStringName; eventProjectionConnectionStringName = section.EventProjectionConnectionStringName; } var connectionConfiguration = provider.Get(eventStoreConnectionStringName); configuration.EventStoreConnectionString = connectionConfiguration.ConnectionString; configuration.EventStoreProviderName = connectionConfiguration.ProviderName; connectionConfiguration = provider.Get(eventProjectionConnectionStringName); configuration.EventProjectionConnectionString = connectionConfiguration.ConnectionString; configuration.EventProjectionProviderName = connectionConfiguration.ProviderName; return(configuration); }
internal void Initialize(IServiceBus bus) { var section = ConfigurationSectionProvider.Open <MessageForwardingSection>("shuttle", "messageForwarding"); if (section == null || section.ForwardingRoutes == null) { return; } var factory = new MessageRouteSpecificationFactory(); foreach (MessageRouteElement mapElement in section.ForwardingRoutes) { var map = _messageRoutes.Find(mapElement.Uri); if (map == null) { map = new MessageRoute(bus.Configuration.QueueManager.GetQueue(mapElement.Uri)); _messageRoutes.Add(map); } foreach (SpecificationElement specificationElement in mapElement) { map.AddSpecification(factory.Create(specificationElement.Name, specificationElement.Value)); } } }
public static IServiceConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <ServiceHostSection>("shuttle", "service"); var configuration = new ServiceConfiguration(); if (section != null) { configuration.WithServiceName(section.ServiceName); if (!string.IsNullOrEmpty(section.Instance)) { configuration.WithInstance(section.Instance); } if (!string.IsNullOrEmpty(section.Username)) { configuration.WithUsername(section.Username); } if (!string.IsNullOrEmpty(section.Password)) { configuration.WithPassword(section.Password); } configuration.WithStartMode(section.StartMode); if (section.DelayedAutoStart) { configuration.WithDelayedAutoStart(); } } return(configuration); }
public void Should_be_able_to_load_the_configuration() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".config\\McAfee.config"); var section = ConfigurationSectionProvider.OpenFile <McAfeeSection>("shuttle", "mcafee", path); Assert.That(section, Is.Not.Null); Assert.That(section.Url, Is.EqualTo("api-url")); Assert.That(section.Username, Is.EqualTo("api-username")); Assert.That(section.Password, Is.EqualTo("api-password")); Assert.That(section.SessionDuration, Is.EqualTo("00:00:05")); Assert.That(section.AnalyzerProfile, Is.EqualTo("analyzer-profile")); Assert.That(section.AcceptableSeverity, Is.EqualTo(3)); Assert.That(section.HeartbeatInterval, Is.EqualTo("00:00:10")); Assert.That(section.PollScanInterval, Is.EqualTo("00:00:15")); var configuration = McAfeeSection.Configuration(path); Assert.That(configuration.Url, Is.EqualTo("api-url")); Assert.That(configuration.Username, Is.EqualTo("api-username")); Assert.That(configuration.Password, Is.EqualTo("api-password")); Assert.That(configuration.SessionDuration, Is.EqualTo(TimeSpan.FromSeconds(5))); Assert.That(configuration.AnalyzerProfile, Is.EqualTo("analyzer-profile")); Assert.That(configuration.AcceptableSeverity, Is.EqualTo(3)); Assert.That(configuration.HeartbeatInterval, Is.EqualTo(TimeSpan.FromSeconds(10))); Assert.That(configuration.PollScanInterval, Is.EqualTo(TimeSpan.FromSeconds(15))); }
public static SubscriptionConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <SubscriptionSection>("shuttle", "subscription"); var configuration = new SubscriptionConfiguration(); var connectionStringName = "Subscription"; if (section != null) { connectionStringName = section.ConnectionStringName; configuration.Subscribe = section.Subscribe; } var settings = ConfigurationManager.ConnectionStrings[connectionStringName]; if (settings == null) { throw new InvalidOperationException(string.Format(Resources.ConnectionStringMissing, connectionStringName)); } configuration.ProviderName = settings.ProviderName; configuration.ConnectionString = settings.ConnectionString; return(configuration); }
public static ISentinelConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <SentinelSection>("shuttle", "sentinel") ?? new SentinelSection(); var result = new SentinelConfiguration(); try { result.SerializerType = Type.GetType(section.SerializerType, true, true); } catch (Exception ex) { throw new ConfigurationErrorsException(string.Format(Resources.TypeNotFoundException, "SerializerType", section.SerializerType, ex.Message)); } var connectionString = ConfigurationManager.ConnectionStrings[section.ConnectionStringName]; if (connectionString == null) { throw new ConfigurationErrorsException(string.Format(Core.Data.Resources.ConnectionStringMissing, section.ConnectionStringName)); } result.ProviderName = connectionString.ProviderName; result.ConnectionString = connectionString.ConnectionString; return(result); }
public static ISentinelConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <SentinelSection>("shuttle", "sentinel") ?? new SentinelSection(); if (section == null) { throw new InvalidOperationException(Resources.MissingConfigurationSectionException); } var result = new SentinelConfiguration { HeartbeatRecoveryDuration = section.HeartbeatRecoveryDuration }; try { result.SerializerType = Type.GetType(section.SerializerType, true, true); } catch (Exception ex) { throw new ConfigurationErrorsException(string.Format(Resources.TypeNotFoundException, "SerializerType", section.SerializerType, ex.Message)); } return(result); }
public static ProjectionConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <ProjectionSection>("shuttle", "projection"); var configuration = new ProjectionConfiguration(); var eventStoreConnectionStringName = "EventStore"; var eventProjectionConnectionStringName = "EventStore"; if (section != null) { eventStoreConnectionStringName = section.EventStoreConnectionStringName; eventProjectionConnectionStringName = section.EventProjectionConnectionStringName; configuration.EventProjectionPrefetchCount = section.EventProjectionPrefetchCount; } var settings = GetConnectionStringSettings(eventStoreConnectionStringName); configuration.EventStoreConnectionString = settings.ConnectionString; configuration.EventStoreProviderName = settings.ProviderName; settings = GetConnectionStringSettings(eventProjectionConnectionStringName); configuration.EventProjectionConnectionString = settings.ConnectionString; configuration.EventProjectionProviderName = settings.ProviderName; return(configuration); }
public static IMessageForwardingConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <MessageForwardingSection>("shuttle", "messageForwarding"); var configuration = new MessageForwardingConfiguration(); if (section?.ForwardingRoutes == null) { return(configuration); } var factory = new MessageRouteSpecificationFactory(); foreach (MessageRouteElement mapElement in section.ForwardingRoutes) { var map = configuration.MessageRoutes.Find(mapElement.Uri); if (map == null) { map = new MessageRoute(new Uri(mapElement.Uri)); configuration.MessageRoutes.Add(map); } foreach (SpecificationElement specificationElement in mapElement) { map.AddSpecification(factory.Create(specificationElement.Name, specificationElement.Value)); } } return(configuration); }
public static IComponentResolverConfiguration GetConfiguration() { var result = new ComponentResolverConfiguration(); var section = ConfigurationSectionProvider.Open <ComponentResolverSection>("shuttle", "componentResolver"); if (section == null) { return(result); } foreach (ComponentResolverElement component in section.Components) { var dependencyType = Type.GetType(component.DependencyType); if (dependencyType == null) { throw new ConfigurationErrorsException( string.Format(Container.Resources.MissingTypeException, component.DependencyType)); } result.AddComponent(new ComponentResolverConfiguration.Component(dependencyType)); } return(result); }
public void Should_be_able_to_load_the_configuration(string file) { var section = ConfigurationSectionProvider.OpenFile <CorruptTransportMessageSection>("shuttle", "corruptTransportMessage", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"config-files\{0}", file))); Assert.IsNotNull(section); Assert.AreEqual(".\\folder", section.Folder); }
public static IBootstrapConfiguration Configuration() { var result = new BootstrapConfiguration(); var section = ConfigurationSectionProvider.Open <BootstrapSection>("shuttle", "bootstrap"); var reflectionService = new ReflectionService(); if (section != null) { result.Scan = section.Scan; foreach (BootstrapAssemblyElement assemblyElement in section.Assemblies) { var assembly = reflectionService.FindAssemblyNamed(assemblyElement.Name); if (assembly == null) { throw new ConfigurationErrorsException( string.Format(Resources.AssemblyNameNotFound, assemblyElement.Name)); } result.AddAssembly(assembly); } } if (result.Scan != BootstrapScan.None) { foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { result.AddAssembly(assembly); } } switch (result.Scan) { case BootstrapScan.All: { foreach (var assembly in reflectionService.GetAssemblies()) { result.AddAssembly(assembly); } break; } case BootstrapScan.Shuttle: { foreach (var assembly in reflectionService.GetMatchingAssemblies("^Shuttle\\.")) { result.AddAssembly(assembly); } break; } } return(result); }
public void Should_be_able_to_load_the_configuration() { var section = ConfigurationSectionProvider.OpenFile <OpswatSection>("shuttle", "opswat", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".config\\Opswat.config")); Assert.That(section, Is.Not.Null); Assert.That(section.ApiKey, Is.EqualTo("api-key")); Assert.That(section.ApiUrl, Is.EqualTo("api-url")); }
public void Should_be_able_to_load_the_configuration(string file) { var section = ConfigurationSectionProvider.OpenFile <ActiveTimeRangeSection>("shuttle", "activeTimeRange", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"config-files\{0}", file))); Assert.IsNotNull(section); Assert.AreEqual("8:00", section.From); Assert.AreEqual("23:00", section.To); }
public void Should_be_able_to_load_the_configuration(string file) { var section = ConfigurationSectionProvider.OpenFile <ServiceHostSection>("shuttle", "service", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@"config-files\{file}")); Assert.IsNotNull(section); Assert.AreEqual("test-service", section.ServiceName); Assert.AreEqual("one", section.Instance); Assert.AreEqual("mr.resistor", section.Username); Assert.AreEqual("ohm", section.Password); Assert.AreEqual(ServiceStartMode.Disabled, section.StartMode); }
public static ISentinelConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <SentinelSection>("shuttle", "sentinel"); var configuration = new SentinelConfiguration(); if (section != null) { configuration.HeartbeatIntervalDuration = section.HeartbeatIntervalDuration; } return(configuration); }
public static MsmqConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <MsmqSection>("shuttle", "msmq"); var configuration = new MsmqConfiguration(); if (section != null) { configuration.LocalQueueTimeoutMilliseconds = section.LocalQueueTimeoutMilliseconds; configuration.RemoteQueueTimeoutMilliseconds = section.RemoteQueueTimeoutMilliseconds; } return(configuration); }
public static IActiveTimeRangeConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <ActiveTimeRangeSection>("shuttle", "activeTimeRange"); var configuration = new ActiveTimeRangeConfiguration(); if (section != null) { configuration.ActiveFromTime = section.From; configuration.ActiveToTime = section.To; } return(configuration); }
public static INetMQConfiguration GetConfiguration() { var section = ConfigurationSectionProvider.Open <NetMQSection>("shuttle", "netmq"); var result = new NetMQConfiguration(); if (section != null) { result.RequestTimeout = section.RequestTimeout; } return(result); }
public static ICorruptTransportMessageConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <CorruptTransportMessageSection>("shuttle", "corruptTransportMessage"); var configuration = new CorruptTransportMessageConfiguration(); if (section != null) { configuration.CorruptTransportMessageFolder = section.Folder; } return(configuration); }
public void Should_be_able_to_load_the_configuration(string file) { var section = ConfigurationSectionProvider.OpenFile <PurgeQueuesSection>("shuttle", "purgeQueues", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"config-files\{0}", file))); Assert.IsNotNull(section); Assert.AreEqual(2, section.Queues.Count); foreach (PurgeQueueElement element in section.Queues) { Console.WriteLine(element.Uri); } }
public static AzureESBConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <AzureESBSection>("shuttle", "azureesb"); var configuration = new AzureESBConfiguration(); if (section != null) { configuration.OperationRetryCount = section.OperationRetryCount; configuration.TransportType = section.TransportType; configuration.SharedAccessKeyName = section.SharedAccessKeyName; } return(configuration); }
public static EventStoreSection Get() { lock (Padlock) { if (!_initialized) { _section = ConfigurationSectionProvider.Open <EventStoreSection>("shuttle", "eventStore"); _initialized = true; } return(_section); } }
public static ServiceBusSection Get() { lock (Padlock) { if (!_initialized) { _section = ConfigurationSectionProvider.Open <ServiceBusSection>("shuttle", "serviceBus"); _initialized = true; } return(_section); } }
public static TransactionScopeSection Get() { lock (Padlock) { if (!_initialized) { _section = ConfigurationSectionProvider.Open <TransactionScopeSection>("shuttle", "transactionScope"); _initialized = true; } return(_section); } }
public static RabbitMQConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <RabbitMQSection>("shuttle", "rabbitmq"); var configuration = new RabbitMQConfiguration(); if (section != null) { configuration.RequestedHeartbeat = section.RequestedHeartbeat; configuration.LocalQueueTimeoutMilliseconds = section.LocalQueueTimeoutMilliseconds; configuration.RemoteQueueTimeoutMilliseconds = section.RemoteQueueTimeoutMilliseconds; configuration.ConnectionCloseTimeoutMilliseconds = section.ConnectionCloseTimeoutMilliseconds; configuration.OperationRetryCount = section.OperationRetryCount; configuration.DefaultPrefetchCount = section.DefaultPrefetchCount; } return(configuration); }
public static AccessConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <AccessSection>("shuttle", "access"); var configuration = new AccessConfiguration(); var connectionStringName = "Access"; if (section != null) { connectionStringName = section.ConnectionStringName; } configuration.ProviderName = GetSettings(connectionStringName).ProviderName; configuration.ConnectionString = GetSettings(connectionStringName).ConnectionString; return(configuration); }
public static IdempotenceConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <IdempotenceSection>("shuttle", "idempotence"); var configuration = new IdempotenceConfiguration(); var connectionStringName = "Idempotence"; if (section != null) { connectionStringName = section.ConnectionStringName; } configuration.ProviderName = GetSettings(connectionStringName).ProviderName; configuration.ConnectionString = GetSettings(connectionStringName).ConnectionString; return(configuration); }
public static SubscriptionConfiguration Configuration() { var section = ConfigurationSectionProvider.Open <SubscriptionSection>("shuttle", "subscription"); var configuration = new SubscriptionConfiguration(); var connectionStringName = "Subscription"; if (section != null) { connectionStringName = section.ConnectionStringName; configuration.Subscribe = section.Subscribe; } configuration.ProviderName = GetSettings(connectionStringName).ProviderName; configuration.ConnectionString = GetSettings(connectionStringName).ConnectionString; return(configuration); }
public DefaultAmazonSqsConfiguration GetConfiguration() { var section = ConfigurationSectionProvider.Open <AmazonSqsSection>("shuttle", "amazonSqs"); var configuration = new DefaultAmazonSqsConfiguration(); if (section != null) { foreach (EndpointElement endpoint in section.Endpoints) { configuration.AddConfiguration(endpoint.Name, new AmazonSQSConfig { ServiceURL = endpoint.ServiceUrl }); } } return(configuration); }