PIbd-23_Sergunov_M.A._SUBD/BookShop/BookShopView/Program.cs

65 lines
2.6 KiB
C#
Raw Permalink Blame History

using BookShopBusinessLogic.BusinessLogics;
using BookShopContracts.BusinessLogicsContracts;
using BookShopContracts.StoragesContracts;
using BookShopDataBaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
namespace BookShopView
{
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);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
_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<IAuthorStorage, AuthorStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IBookStorage, BookStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IGenreStorage, GenreStorage>();
services.AddTransient<IAuthorLogic, AuthorLogic>();
services.AddTransient<IBookLogic, BookLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IGenreLogic, GenreLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormAuthor>();
services.AddTransient<FormAuthors>();
services.AddTransient<Form<EFBFBD>reateOrder>();
services.AddTransient<FormBook>();
services.AddTransient<FormBooks>();
services.AddTransient<FormBookAuthor>();
services.AddTransient<FormGenre>();
services.AddTransient<FormGenres>();
services.AddTransient<FormClients>();
services.AddTransient<FormClient>();
services.AddTransient<FormTests>();
}
}
}