// Async application starting point public async Task <ApplicationRunResponse> Run() { ApplicationRunResponse response = new ApplicationRunResponse(); // TODO : Write your own application code here. Log.Information($"{_emailSettings.Value.DefaultFromName} <{_emailSettings.Value.DefaultFromEmail}>"); return(response); }
/// <summary> /// Entry point of the project. /// Notice the method is returning async task instead of void in order to support async programming. /// </summary> /// <param name="args"></param> /// <returns></returns> public static async Task Main(string[] args) { try { Configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true) .AddCommandLine(args) .AddEnvironmentVariables() .Build(); // configure serilog Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(Configuration) .Enrich.FromLogContext() .Enrich.WithMachineName() .CreateLogger(); Log.Information("Starting up..."); // Create service collection and configure our services var services = ConfigureServices(); // Generate a provider var serviceProvider = services.BuildServiceProvider(); // Kick off the actual application ApplicationRunResponse response = await serviceProvider.GetService <Application>().Run(); Log.Information("Shutting down..."); } catch (Exception ex) { Log.Fatal(ex, "Application terminated unexpectedly"); } finally { Log.CloseAndFlush(); } }