WIP dependency Injection
This commit is contained in:
39
DaSaSo.Wpf/App.xaml.cs
Normal file
39
DaSaSo.Wpf/App.xaml.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using DaSaSo.EntityFramework;
|
||||
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 void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
IServiceProvider serviceProvider = CreateServiceProvider();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user