-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
88 lines (75 loc) · 3.13 KB
/
App.xaml.cs
File metadata and controls
88 lines (75 loc) · 3.13 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Windows;
using DayZTediratorToolz.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Configuration;
using System.IO;
using System.Windows.Documents;
using DayZTediratorToolz.Services.ToolConfigService;
using DayZTediratorToolz.Views;
using DayZTediratorToolz.Views.AdminPanel;
using DayZTediratorToolz.Views.Types;
namespace DayZTediratorToolz
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
private readonly IHost host;
private const string configPath = "AppConfiguration.json";
public App()
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NTA0ODQwQDMxMzkyZTMyMmUzMGVyRWxHSFFkYWFmeDVRNzFwZmhSblliNFpBc1NDblZlRVJvWXJPWmxNMEU9");
host = new HostBuilder()
.ConfigureServices((hostContext, services) =>
{
var appConfigData = string.Empty;
try
{
appConfigData = File.ReadAllText(configPath);
}
catch (Exception e)
{
throw;
}
services.AddSingleton<IAppSettingsManager>(provider =>
{
return new AppSettingsManager(appConfigData);
});
services.AddSingleton<IServerInspectionService>(provider => new ServerInspectionService());
services.AddSingleton<IControllerService>(provider => new ControllerService());
services.AddSingleton<ITypesConvertorService>(provider => new TypesConvertorService());
services.AddSingleton<IGeneralHelperService>(provider => new GeneralHelperService());
services.AddSingleton<INotificationService>(provider => new NotificationService());
services.AddSingleton<IToolConfigService>(provider => new ToolConfigService());
services.AddSingleton<HomeView>();
services.AddSingleton<AdminPanelView>();
services.AddSingleton<TypesEditorView>();
services.AddSingleton<MainWindow>();
}).Build();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
var mainWindow = host.Services.GetService<MainWindow>();
host.Services.GetService<IControllerService>().InitializeViews(
host.Services.GetService<HomeView>(),
host.Services.GetService<AdminPanelView>(),
host.Services.GetService<TypesEditorView>()
);
mainWindow.Closed += (s,e) => {
ShutItDown();
};
mainWindow.Show();
}
private void ShutItDown()
{
using (host)
{
host.StopAsync();
}
Current.Shutdown();
}
}
}