Esempio n. 1
0
        // This is where you register dependencies, add services to the
        // container. This method is called by the runtime, before the
        // Configure method below.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Setup (not enabling yet) CORS
            services.AddCors();

            // ASP.Net 2.2 -> 3.1 converstion
            services.AddLogging(builder => builder.AddConsole());

            // Enable controllers and enable Newtonsoft-compatibile JSON handling
            services.AddControllers().AddNewtonsoftJson();

            // Prepare DI container
            this.ApplicationContainer = DependencyResolution.Setup(services);

            // Print some useful information at bootstrap time
            this.PrintBootstrapInfo(this.ApplicationContainer);

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