Ejemplo n.º 1
0
        /// <summary>
        /// Adds Horse connector with configuration
        /// </summary>
        public static IServiceCollection AddHorseBus(this IServiceCollection services, Action <HorseConnectorBuilder> config)
        {
            HorseConnectorBuilder builder = new HorseConnectorBuilder(services);

            config(builder);

            HmqStickyConnector connector = builder.Build();

            AddConsumersMicrosoftDI(services, connector, builder);
            services.AddSingleton(connector);
            services.AddSingleton(connector.Bus);
            services.AddSingleton(connector.Bus.Direct);
            services.AddSingleton(connector.Bus.Queue);
            services.AddSingleton(connector.Bus.Route);

            return(services);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds Horse connector with configuration
        /// </summary>
        public static IServiceCollection AddHorseBus <TIdentifier>(this IServiceCollection services, Action <HorseConnectorBuilder> config)
        {
            HorseConnectorBuilder builder = new HorseConnectorBuilder(services);

            config(builder);

            HmqStickyConnector <TIdentifier> connector = builder.Build <TIdentifier>();

            AddConsumersMicrosoftDI(services, connector, builder);
            services.AddSingleton(connector);

            HorseBus <TIdentifier> bus = (HorseBus <TIdentifier>)connector.Bus;

            services.AddSingleton <IHorseBus <TIdentifier> >(bus);
            services.AddSingleton <IHorseDirectBus <TIdentifier> >((HorseDirectBus <TIdentifier>)bus.Direct);
            services.AddSingleton <IHorseQueueBus <TIdentifier> >((HorseQueueBus <TIdentifier>)bus.Queue);
            services.AddSingleton <IHorseRouteBus <TIdentifier> >((HorseRouteBus <TIdentifier>)bus.Route);

            return(services);
        }