-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
59 lines (51 loc) · 1.78 KB
/
Copy pathApp.xaml.cs
File metadata and controls
59 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using Microsoft.Extensions.Configuration;
using RDPShadow.Services;
namespace RDPShadow
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private MainViewModel _viewModel;
public App()
{
_viewModel = Bootstrap();
}
private static MainViewModel Bootstrap()
{
ConfigurationBuilder configBuilder = new ConfigurationBuilder();
IConfiguration config = configBuilder
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appconfig.json")
.AddJsonFile("appconfig.Development.json", true)
.Build();
string domain = config["domain"];
string containerDc = config["containerDc"];
var computerService = new ComputerRepository(domain, containerDc);
var sessionService = new SessionRepository();
var rdpService = new RDPService(computerService, sessionService);
return new MainViewModel(rdpService);
}
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
MessageBox.Show($"An error occured: {e.Exception.Message}","RDPShadow", MessageBoxButton.OK, MessageBoxImage.Error);
Shutdown(1);
}
private void App_OnStartup(object sender, StartupEventArgs e)
{
var mainWindow = new MainWindow(_viewModel);
mainWindow.Show();
}
}
}