60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using EmployeeManagmentDataBaseImplement;
|
|
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Windows;
|
|
using Microsoft.Extensions.Logging;
|
|
using EmployeeManagmentContracts.StoragesContracts;
|
|
using EmployeeManagmentDataBaseImplement.Implements;
|
|
|
|
namespace EmployeeManagmentView
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
private static ServiceProvider? _serviceProvider;
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
var serviceCollection = new ServiceCollection();
|
|
ConfigureServices(serviceCollection);
|
|
_serviceProvider = serviceCollection.BuildServiceProvider();
|
|
|
|
try
|
|
{
|
|
var mainWindow = _serviceProvider.GetRequiredService<MainWindow>();
|
|
mainWindow.Show();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при открытии MainWindow", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
|
|
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
private static void ConfigureServices(ServiceCollection services)
|
|
{
|
|
services.AddLogging(configure => configure.AddConsole());
|
|
|
|
services.AddTransient<IEmployeeStorage, EmployeeStorage>();
|
|
services.AddTransient<IPhisicalPersonStorage, PhisicalPersonStorage>();
|
|
services.AddTransient<ISalaryStorage, SalaryStorage>();
|
|
services.AddTransient<IVacationStorage, VacationStorage>();
|
|
|
|
services.AddTransient<IPhisicalPersonLogic, PhisicalPersonLogic>();
|
|
services.AddTransient<IEmployeeLogic, EmployeeLogic>();
|
|
|
|
services.AddTransient<MainWindow>();
|
|
services.AddTransient<EmployeesWindow>();
|
|
services.AddTransient<SalariesWindow>();
|
|
services.AddTransient<VacationsWindow>();
|
|
|
|
|
|
}
|
|
}
|
|
}
|