45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using EmployeeManager.Model.Data;
|
|
using EmployeeManager.View;
|
|
using EmployeeManager.ViewModel;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Windows;
|
|
|
|
namespace EmployeeManager
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
public IServiceProvider ServiceProvider { get; private set; }
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
// Регистрация DbContext
|
|
services.AddDbContext<ApplicationConext>();
|
|
|
|
// Регистрация сервисов
|
|
services.AddScoped<IPhysicalPersonService, PhysicalPersonService>();
|
|
|
|
// Регистрация ViewModel
|
|
services.AddTransient<DataManageViewModel>();
|
|
|
|
// Регистрация окон
|
|
services.AddTransient<MainWindow>();
|
|
|
|
// Создаем ServiceProvider
|
|
ServiceProvider = services.BuildServiceProvider();
|
|
|
|
// Открываем главное окно
|
|
var mainWindow = ActivatorUtilities.CreateInstance<MainWindow>(ServiceProvider);
|
|
mainWindow.Show();
|
|
}
|
|
|
|
}
|
|
|
|
}
|