using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
namespace OnlineSalesAutoCrop.CoreAPI
{
///
///
///
public class Program
{
///
///
///
protected Program()
{
//Noting to do here
}
///
///
///
///
public static void Main(string[] args)
{
bool hasError = false;
IHost host = CreateHostBuilder(args).Build();
ILogger logger = host.Services.GetRequiredService>();
try
{
logger.LogInformation("Starting the application...");
host.Run();
}
catch (Exception e)
{
hasError = true;
logger.LogCritical(exception: e, message: "Application terminated unexpectedly.");
}
finally
{
if (hasError)
{
logger.LogCritical(message: "Application encountered an error.");
}
else
{
logger.LogInformation(message: "Application was started.");
}
}
}
///
///
///
///
///
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
logging.AddDebug();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseIISIntegration();
webBuilder.UseStartup();
});
}
}