PIbd-32.-Stroev-V.M.-COP/WinFormsLibrary1/WinFormsApp1/Program.cs
2024-11-14 20:27:58 +04:00

53 lines
1.7 KiB
C#

using BusinessLogics.BusinessLogics;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace WinFormsApp1
{
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<Form1>());
}
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>();
}
}
}