PIbd-22_Shabunov_O.A._AutoW.../AutoWorkshop/Program.cs
2024-02-21 10:36:30 +04:00

49 lines
1.8 KiB
C#

using AutoWorkshopContracts.BusinessLogicContracts;
using AutoWorkshopContracts.StoragesContracts;
using AutoWorkshopView.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace AutoWorkshopView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread]
static void Main()
{
var Services = new ServiceCollection();
ConfigureServices(Services);
_serviceProvider = Services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<MainForm>());
}
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<IIceCreamStorage, IceCreamStorage>();
Services.AddTransient<IComponentLogic, ComponentLogic>();
Services.AddTransient<IOrderLogic, OrderLogic>();
Services.AddTransient<IIceCreamLogic, IceCreamLogic>();
Services.AddTransient<MainForm>();
Services.AddTransient<ComponentForm>();
Services.AddTransient<ComponentsForm>();
Services.AddTransient<OrderForm>();
Services.AddTransient<IceCreamForm>();
Services.AddTransient<IceCreamComponentForm>();
Services.AddTransient<IceCreamsForm>();
}
}
}