PIAPS_CW/WinFormsApp/Program.cs

52 lines
2.0 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>();
}
}
}