ISEbd-12_Sinelnikova_A.V._S.../ProjectCruiser/Program.cs

45 lines
1.7 KiB
C#
Raw Permalink Normal View History

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
2024-02-08 09:06:32 +04:00
namespace ProjectCruiser
{
internal static class Program
{
/// <summary>
2024-03-21 10:52:11 +04:00
/// The main entry point for the application.
2024-02-08 09:06:32 +04:00
/// </summary>
[STAThread]
static void Main()
{
2024-03-21 10:52:11 +04:00
// To customize application configuration such as set high DPI settings or default font, see https://aka.ms/applicationconfiguration.
2024-02-08 09:06:32 +04:00
ApplicationConfiguration.Initialize();
ServiceCollection services = new();
ConfigureServices(services);
using ServiceProvider serviceProvider = services.BuildServiceProvider();
Application.Run(serviceProvider.GetRequiredService<FormCruisersCollection>());
2024-02-08 09:06:32 +04:00
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormCruisersCollection>().AddLogging(option =>
{
string[] path = Directory.GetCurrentDirectory().Split('\\');
string pathNeed = "";
for (int i = 0; i < path.Length - 3; i++)
{
pathNeed += path[i] + "\\";
}
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: $"{pathNeed}serilogConfig.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
option.AddSerilog(logger);
});
}
2024-02-08 09:06:32 +04:00
}
}