CourseWork_CompShop/ComputerShopProvider/ComputerShopView/Program.cs

45 lines
1.8 KiB
C#
Raw Normal View History

2023-04-07 16:53:49 +04:00
using ComputerShopBusinessLogic.BusinessLogics;
using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.StorageContracts;
using ComputerShopDatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2023-04-05 18:31:49 +04:00
namespace ComputerShopView
{
internal static class Program
{
2023-04-07 16:53:49 +04:00
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2023-04-05 18:31:49 +04:00
/// <summary>
2023-04-07 16:53:49 +04:00
/// The main entry point for the application.
2023-04-05 18:31:49 +04:00
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
2023-04-07 16:53:49 +04:00
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<Form1>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IPurchaseStorage, PurchaseStorage>();
services.AddTransient<IAssemblyStorage, AssemblyStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IPurchaseLogic, PurchaseLogic>();
services.AddTransient<IAssemblyLogic, AssemblyLogic>();
2023-04-05 18:31:49 +04:00
}
}
}