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

63 lines
2.6 KiB
C#

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;
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);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormBookCreate>());
}
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<IUserStorage, UserStorage>();
services.AddTransient<IPublisherStorage, PublisherStorage>();
services.AddTransient<IAuthorLogic, AuthorLogic>();
services.AddTransient<IBookLogic, BookLogic>();
services.AddTransient<IGenreLogic, GenreLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IUserLogic, UserLogic>();
services.AddTransient<IPublisherLogic, PublisherLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormGenre>();
services.AddTransient<FormGenres>();
services.AddTransient<FormAuthor>();
services.AddTransient<FormAuthors>();
services.AddTransient<FormUser>();
services.AddTransient<FormUsers>();
services.AddTransient<FormPublisher>();
services.AddTransient<FormPublishers>();
services.AddTransient<FormBookCreate>();
}
}
}