Files
DaSaSo/DaSaSo.Wpf/App.xaml.cs
2021-09-13 20:09:06 +02:00

44 lines
1.3 KiB
C#

using DaSaSo.Domain.Model;
using DaSaSo.Domain.Services;
using DaSaSo.Domain.Services.ClientServices;
using DaSaSo.EntityFramework;
using DaSaSo.EntityFramework.Services;
using DaSaSo.ViewModel;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace DaSaSo.Wpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override async void OnStartup(StartupEventArgs e)
{
IServiceProvider serviceProvider = CreateServiceProvider();
IDataService<Client> clientService = new ClientDataService(new DaSaSoDbContextFactory());
var d = await clientService.GetAll();
base.OnStartup(e);
MainWindow? window = new MainWindow() { DataContext = new MainWindowViewModel() };
window.Show();
}
private IServiceProvider CreateServiceProvider()
{
IServiceCollection services = new ServiceCollection();
services.AddSingleton<DaSaSoDbContext>();
//services.AddSingleton<IDataService<Client>, ClientDataService>();
return services.BuildServiceProvider();
}
}
}