PIAPS_CW/WinFormsApp/Program.cs
2024-06-23 21:35:37 +04:00

54 lines
2.1 KiB
C#

using System;
using Microsoft.Extensions.DependencyInjection;
using NLog.Extensions.Logging;
using Microsoft.Extensions.Logging;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Contracts.BusinessLogicContracts;
using BusinessLogic.BusinessLogic;
namespace WinFormsApp
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </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>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<ISupplyStorage, SupplyStorage>();
//services.AddTransient<ISupplyDocStorage, SupplyDocStorage>();
services.AddTransient<IProductStorage, ProductStorage>();
services.AddTransient<ISupplierStorage, SupplierStorage>();
//services.AddTransient<, ImplementerStorage>();
services.AddTransient<ISupplyLogic, SupplyLogic>();
services.AddTransient<ISupplierLogic, SupplierLogic>();
services.AddTransient<IProductLogic, ProductLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormProducts>();
services.AddTransient<FormSuppliers>();
services.AddTransient<FormSupply>();
services.AddTransient<FormSupplyProduct>();
}
}
}