PIbd-32.-Stroev-V.M.-COP/WinFormsLibrary1/WinFormsApp1/Program.cs

53 lines
1.7 KiB
C#
Raw Normal View History

2024-11-11 22:20:20 +04:00
using BusinessLogics.BusinessLogics;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
2024-10-14 13:05:17 +04:00
namespace WinFormsApp1
{
internal static class Program
{
2024-11-11 22:20:20 +04:00
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2024-10-14 13:05:17 +04:00
/// <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();
2024-11-11 22:20:20 +04:00
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<Form1>());
2024-11-11 22:20:20 +04:00
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
});
services.AddTransient<IProductStorage, ProductStorage>();
services.AddTransient<ICategoryStorage, CategoryStorage>();
services.AddTransient<IProductLogic, ProductLogic>();
services.AddTransient<ICategoryLogic, CategoryLogic>();
services.AddTransient<CategoryForm>();
services.AddTransient<ProductForm>();
services.AddTransient<MainForm>();
services.AddTransient<Form1>();
2024-10-14 13:05:17 +04:00
}
}
}