PIbd-22_Chubykina_SUBD_Book.../Bookshop/BookshopView/Program.cs

53 lines
2.0 KiB
C#
Raw Normal View History

using BookshopBusinessLogic.BusinessLogics;
using BookshopContracts.BusinessLogicsContracts;
using BookshopContracts.StorageContracts;
using BookshopDatabaseImplement.Implemets;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
2024-05-14 17:42:58 +04:00
namespace BookshopView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2024-05-14 17:42:58 +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();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormAuthors>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IAuthorStorage, AuthorStorage>();
services.AddTransient<IGenreStorage, GenreStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IAuthorLogic, AuthorLogic>();
services.AddTransient<IGenreLogic, GenreLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormGenre>();
services.AddTransient<FormGenres>();
services.AddTransient<FormAuthor>();
services.AddTransient<FormAuthors>();
2024-05-14 17:42:58 +04:00
}
}
}