Exemple #1
0
        public static RabbitConsumerApp <TImplementation, T> AddRabbitConsumer <T, TImplementation>(this IServiceCollection services, Action <RabbitConsumerOptions> setup)
            where T : class
            where TImplementation : class, IRabbitConsumer <T>
        {
            var options = new RabbitConsumerOptions();

            setup.Invoke(options);

            services.AddSingleton(options);

            services.AddSingleton <IRabbitConsumer <T>, TImplementation>();
            services.AddSingleton <RabbitConsumerApp <TImplementation, T> >();

            var provider = services.BuildServiceProvider();

            return(provider.GetService <RabbitConsumerApp <TImplementation, T> >());
        }
Exemple #2
0
 public RabbitConsumerApp(IRabbitConnectionManager manager, T consumer, RabbitConsumerOptions options)
 {
     _manager  = manager;
     _consumer = consumer;
     _options  = options;
 }