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 { /// /// Interaction logic for App.xaml /// public partial class App : Application { public IServiceProvider ServiceProvider { get; private set; } protected override void OnStartup(StartupEventArgs e) { var services = new ServiceCollection(); // Регистрация DbContext services.AddDbContext(); // Регистрация сервисов services.AddScoped(); // Регистрация ViewModel services.AddTransient(); // Регистрация окон services.AddTransient(); // Создаем ServiceProvider ServiceProvider = services.BuildServiceProvider(); // Открываем главное окно var mainWindow = ActivatorUtilities.CreateInstance(ServiceProvider); mainWindow.Show(); } } }