public Startup(IConfiguration configuration, IWebHostEnvironment _environment) { Configuration = configuration; ConfigurationRoot = new ConfigurationBuilder() .SetBasePath(_environment.ContentRootPath) .AddJsonFile("appsettings.json") .Build(); InfraConfig = new InfraConfig(ConfigurationRoot["ConnectionString"]); }
static void Main(string[] args) { IScopeFactory scopeFactory = InfraConfig.Initialize(); using (IAppLayer app = scopeFactory.CreateAppLayer()) { IPaymentService payment = app.GetService <IPaymentService>(); IOrderPlacementService orderPlacement = app.GetService <IOrderPlacementService>(); Console.WriteLine("\n#### IPaymentService.PayOrder ####\n"); payment.PayOrder(orderId: 1, amount: 30); app.UnitOfWork.Save(); Console.WriteLine("\n#### IOrderPlacementService.ShipOrder ####\n"); orderPlacement.ShipOrder(orderId: 1, address: "G1Q1Q9"); app.UnitOfWork.Save(); } Console.ReadKey(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // Infrastructure InfraConfig.Up(); var applicationLifetime = app.ApplicationServices.GetRequiredService <IApplicationLifetime>(); applicationLifetime.ApplicationStopping.Register(InfraConfig.Down); // Markdown app.UseMarkdown(); app.UseStaticFiles(); app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List <string> { "index.md", "index.html" } }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}", defaults: new { controller = "Topics", action = "Index" }); }); }