Exemple #1
0
        // Application entry point
        public static void Main(string[] args)
        {
            IConfig config = DependencyResolution.GetConfig();

            /*
             * Kestrel is a cross-platform HTTP server based on libuv,
             * a cross-platform asynchronous I/O library.
             * https://docs.microsoft.com/aspnet/core/fundamentals/servers
             */
            var host = new WebHostBuilder()
                       .UseUrls("http://*:" + config.Port)
                       .UseKestrel(options => { options.AddServerHeader = false; })
                       .UseIISIntegration()
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }
        // This is where you register dependencies and add services to the
        // container. This method is called by the runtime, before the
        // Configure method below, to configure the app's services.
        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.Init(services);

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

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