Build() static private méthode

static private Build ( BusBuilderConfiguration configuration ) : Bus
configuration BusBuilderConfiguration
Résultat Bus
        private void ClearMeABus()
        {
            // Filter types we care about to only our own test's namespace. It's a performance optimisation because creating and
            // deleting queues and topics is slow.
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {"Some.Namespace.That.Does.Not.Exist"});
            var messageBroker = new DefaultMessageHandlerFactory(typeProvider);

            var logger = new ConsoleLogger();

            var busBuilder = new BusBuilder().Configure()
                                             .WithNames("IntegrationTestHarness", Environment.MachineName)
                                             .WithConnectionString(CommonResources.ConnectionString)
                                             .WithTypesFrom(typeProvider)
                                             .WithCommandHandlerFactory(messageBroker)
                                             .WithRequestHandlerFactory(messageBroker)
                                             .WithMulticastEventHandlerFactory(messageBroker)
                                             .WithCompetingEventHandlerFactory(messageBroker)
                                             .WithMulticastRequestHandlerFactory(messageBroker)
                                             .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                             .WithLogger(logger)
                                             .WithDebugOptions(
                                                 dc =>
                                                     dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                         "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                ;

            using (var bus = busBuilder.Build())
            {
                bus.Start();
            }
        }
        private async Task ClearMeABus(IConfigurationScenario<TransportConfiguration> scenario)
        {
            using (var instance = scenario.CreateInstance())
            {
                // We want a namespace that doesn't exist here so that all the queues and topics are removed.
                var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {"Some.Namespace.That.Does.Not.Exist"});
                var transportConfiguration = instance.Configuration;

                var busBuilder = new BusBuilder().Configure()
                                                 .WithTransport(transportConfiguration)
                                                 .WithRouter(new DestinationPerMessageTypeRouter())
                                                 .WithSerializer(new JsonSerializer())
                                                 .WithDeliveryRetryStrategy(new ImmediateRetryDeliveryStrategy())
                                                 .WithDependencyResolver(new DependencyResolver(typeProvider))
                                                 .WithNames("MyTestSuite", Environment.MachineName)
                                                 .WithTypesFrom(typeProvider)
                                                 .WithDefaultTimeout(TimeSpan.FromSeconds(TimeoutSeconds))
                                                 .WithHeartbeatInterval(TimeSpan.MaxValue)
                                                 .WithLogger(_logger)
                                                 .WithDebugOptions(
                                                     dc =>
                                                         dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                             "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                    ;

                using (var bus = busBuilder.Build())
                {
                    await bus.Start();
                    await bus.Stop();
                }
            }
        }
Exemple #3
0
        public Bus Build()
        {
            if (TypeProvider != null)
            {
                if (Serializer == null)
                {
                    Serializer = new DataContractSerializer(TypeProvider);
                }

                if (DependencyResolver == null)
                {
                    DependencyResolver = new DependencyResolver(TypeProvider);
                }
            }

            return(BusBuilder.Build(this));
        }
        private async Task<Bus> BuildMeABus(IConfigurationScenario<TransportConfiguration> scenario)
        {
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {GetType().Namespace});

            using (var instance = scenario.CreateInstance())
            {
                var transportConfiguration = instance.Configuration;

                var configuration = new BusBuilder().Configure()
                                                    .WithTransport(transportConfiguration)
                                                    .WithRouter(new DestinationPerMessageTypeRouter())
                                                    .WithSerializer(new JsonSerializer())
                                                    .WithDeliveryRetryStrategy(new ImmediateRetryDeliveryStrategy())
                                                    .WithDependencyResolver(new DependencyResolver(typeProvider))
                                                    .WithNames("MyTestSuite", Environment.MachineName)
                                                    .WithTypesFrom(typeProvider)
                                                    .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                                    .WithHeartbeatInterval(TimeSpan.MaxValue)
                                                    .WithLogger(_logger)
                    ;

                var bus = configuration.Build();
                await bus.Start();
                await bus.Stop();
                return bus;
            }
        }
 public Bus Build()
 {
     AssertConfigurationIsValid();
     return(BusBuilder.Build(this));
 }