Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            var jwtTokenConfig = SetupAppSettings(services);

            SetupAuthentication(services, jwtTokenConfig);
            SetupApiVersioning(services);
            SetupSwagger(services);

            DependencyRegistrar.RegisterComponents(services);
        }
        private IServiceProvider SetupDependencies(IServiceCollection services)
        {
            var builder = new ContainerBuilder();

            // Register dependencies, populate the services from
            // the collection, and build the container.

            builder.Populate(services);
            DependencyRegistrar.RegisterComponents(builder);

            this.ApplicationContainer = builder.Build();

            AppDomain.CurrentDomain.ProcessExit += (s, e) => Log.CloseAndFlush();

            // Create the IServiceProvider based on the container.
            return(new AutofacServiceProvider(this.ApplicationContainer));
        }