PIbd-23_Sergunov_M.A._GiftShop/GiftShop/GiftShopView/Program.cs

47 lines
1.8 KiB
C#
Raw Normal View History

2023-03-31 19:55:55 +04:00
using GiftShopBusinessLogic.BusinessLogics;
using GiftShopContracts.BusinessLogicsContracts;
using GiftShopContracts.StoragesContracts;
using GiftShopListImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2023-03-05 23:33:53 +04:00
namespace GiftShopView
{
internal static class Program
{
2023-03-31 19:55:55 +04:00
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2023-03-05 23:33:53 +04:00
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
2023-03-31 19:55:55 +04:00
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
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<IGiftStorage, GiftStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IGiftLogic, GiftLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormGift>();
services.AddTransient<FormGiftComponent>();
services.AddTransient<FormGifts>();
2023-03-05 23:33:53 +04:00
}
}
}