Exemple #1
0
        public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app, IConsumerSubscriptions consumerSubscriptions)
        {
            _consumerSubscriptions = consumerSubscriptions;

            var life = app.ApplicationServices.GetService <IApplicationLifetime>();

            life.ApplicationStarted.Register(OnStarted);
            life.ApplicationStopping.Register(OnStopping);

            return(app);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = "Sample Library ",
                    Version = "v1",
                });
            });

            services.AddControllers();
            services.AddDbContext(Configuration);
            services.Register();

            var serviceProvider = services.BuildServiceProvider();

            _consumerSubscriptions = (IConsumerSubscriptions)serviceProvider.GetRequiredService(typeof(IConsumerSubscriptions));
        }