From d062d68229b7ea8d2dee0a7c765d584394bfd694 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 25 Jan 2022 22:29:52 +0300 Subject: [PATCH] updated applications --- .../src/EShopOnAbp.AuthServer/Program.cs | 65 +++++++++-------- .../src/EShopOnAbp.AuthServer/Startup.cs | 19 ----- .../src/EShopOnAbp.PublicWeb/Program.cs | 69 +++++++++---------- .../src/EShopOnAbp.PublicWeb/Startup.cs | 25 ------- 4 files changed, 63 insertions(+), 115 deletions(-) delete mode 100644 apps/auth-server/src/EShopOnAbp.AuthServer/Startup.cs delete mode 100644 apps/public-web/src/EShopOnAbp.PublicWeb/Startup.cs diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/Program.cs b/apps/auth-server/src/EShopOnAbp.AuthServer/Program.cs index b236243d..efe95993 100644 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/Program.cs +++ b/apps/auth-server/src/EShopOnAbp.AuthServer/Program.cs @@ -1,46 +1,45 @@ using System; using System.Threading.Tasks; using EShopOnAbp.Shared.Hosting.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; -namespace EShopOnAbp.AuthServer +namespace EShopOnAbp.AuthServer; + +public class Program { - public class Program + public static async Task Main(string[] args) { - public static async Task Main(string[] args) - { - var assemblyName = typeof(Program).Assembly.GetName().Name; - - SerilogConfigurationHelper.Configure(assemblyName); + var assemblyName = typeof(Program).Assembly.GetName().Name; - try - { - Log.Information($"Starting {assemblyName}."); - await CreateHostBuilder(args).Build().RunAsync(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } - } + SerilogConfigurationHelper.Configure(assemblyName); - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration(build => - { - build.AddJsonFile("appsettings.secrets.json", optional: true); - }) - .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }) + try + { + Log.Information($"Starting {assemblyName}."); + var builder = WebApplication.CreateBuilder(args); + builder.Host + .AddAppSettingsSecretsJson() .UseAutofac() .UseSerilog(); + + await builder.AddApplicationAsync(); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); + + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } } -} +} \ No newline at end of file diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/Startup.cs b/apps/auth-server/src/EShopOnAbp.AuthServer/Startup.cs deleted file mode 100644 index f20bcf34..00000000 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/Startup.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; - -namespace EShopOnAbp.AuthServer -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.InitializeApplication(); - } - } -} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Program.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Program.cs index 213a1f8d..305cbc91 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Program.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Program.cs @@ -1,52 +1,45 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using EShopOnAbp.Shared.Hosting.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Serilog; -namespace EShopOnAbp.PublicWeb +namespace EShopOnAbp.PublicWeb; + +public class Program { - public class Program + public static async Task Main(string[] args) { - public static async Task Main(string[] args) - { - var assemblyName = typeof(Program).Assembly.GetName().Name; - - SerilogConfigurationHelper.Configure(assemblyName); + var assemblyName = typeof(Program).Assembly.GetName().Name; - try - { - Log.Information($"Starting {assemblyName}."); - await CreateHostBuilder(args).Build().RunAsync(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } - } + SerilogConfigurationHelper.Configure(assemblyName); - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration(build => - { - build.AddJsonFile("appsettings.secrets.json", optional: true); - }) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) + try + { + Log.Information($"Starting {assemblyName}."); + var builder = WebApplication.CreateBuilder(args); + builder.Host + .AddAppSettingsSecretsJson() .UseAutofac() .UseSerilog(); + + await builder.AddApplicationAsync(); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); + + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Startup.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Startup.cs deleted file mode 100644 index 2322543f..00000000 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Startup.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace EShopOnAbp.PublicWeb -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.InitializeApplication(); - } - } -} \ No newline at end of file