PIbd-22_Bulatova_K.R._Compu.../ComputersShop/ComputersShopView/Program.cs

73 lines
2.7 KiB
C#
Raw Normal View History

using ComputersShopBusinessLogic.BusinessLogics;
2024-03-26 20:07:16 +04:00
using ComputersShopContracts.BusinessLogicsContracts;
using ComputersShopContracts.StoragesContracts;
using ComputersShopFileImplement.Implements;
using ComputersShopView;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
2024-02-13 21:31:29 +04:00
namespace ComputersShopView
{
internal static class Program
{
/// <summary>
/// IoC-êîíòåéíåð
/// </summary>
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2024-02-13 21:31:29 +04:00
/// <summary>
/// The main entry point for the application.
2024-02-13 21:31:29 +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();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
/// <summary>
/// Íàñòðîéêà IoC-êîíòåéíåðà è ëîããåðà
/// </summary>
/// <param name="services"></param>
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>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IComputerLogic, ComputerLogic>();
2024-03-26 20:07:16 +04:00
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormComputer>();
services.AddTransient<FormComputerComponent>();
services.AddTransient<FormComputers>();
2024-03-26 20:07:16 +04:00
services.AddTransient<FormShops>();
services.AddTransient<FormShop>();
2024-03-26 20:07:16 +04:00
services.AddTransient<FormSupply>();
services.AddTransient<FormSell>();
2024-02-13 21:31:29 +04:00
}
}
}