PIbd-23_Bogdanov_D.S._Compu.../ComputersShop/Program.cs

57 lines
2.4 KiB
C#
Raw Permalink Normal View History

2023-02-12 15:03:53 +04:00
using ComputerShopBusinessLogic.BusinessLogics;
using ComputerShopContracts.BusinessLogicsContracts;
using ComputerShopContracts.StoragesContracts;
using ComputerShopListImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2023-01-29 16:13:03 +04:00
namespace ComputersShop
{
internal static class Program
{
2023-02-12 15:03:53 +04:00
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2023-01-29 16:13:03 +04:00
/// <summary>
2023-02-12 15:03:53 +04:00
/// The main entry point for the application.
2023-01-29 16:13:03 +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-02-12 15:03:53 +04:00
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
2023-01-29 16:13:03 +04:00
}
2023-02-12 15:03:53 +04:00
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IComputerStorage, ComputerStorage>();
2023-03-26 20:47:20 +04:00
services.AddTransient<IShopStorage, ShopStorage>();
2023-02-12 15:03:53 +04:00
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IComputerLogic, ComputerLogic>();
2023-03-26 20:47:20 +04:00
services.AddTransient<IShopLogic, ShopLogic>();
2023-02-12 15:03:53 +04:00
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormComputer>();
services.AddTransient<FormComputerComponent>();
2023-03-26 20:47:20 +04:00
services.AddTransient<FormComputers>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormShopSupply>();
2023-02-12 15:03:53 +04:00
}
2023-01-29 16:13:03 +04:00
}
}