-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
64 lines (55 loc) · 2.12 KB
/
App.xaml.cs
File metadata and controls
64 lines (55 loc) · 2.12 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
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors.
// All Rights Reserved.
using ReflectionEventing.Demo.Wpf.Services;
using ReflectionEventing.Demo.Wpf.ViewModels;
using ReflectionEventing.DependencyInjection;
using ReflectionEventing.DependencyInjection.Services;
namespace ReflectionEventing.Demo.Wpf;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private static readonly IHost Host = Microsoft
.Extensions.Hosting.Host.CreateDefaultBuilder()
.ConfigureAppConfiguration(c =>
{
_ = c.SetBasePath(Directory.GetCurrentDirectory());
_ = c.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
})
.ConfigureServices(
(context, services) =>
{
_ = services.AddHostedService<ApplicationHostService>();
_ = services.AddHostedService<BackgroundTickService>();
_ = services.AddSingleton<MainWindow>();
_ = services.AddSingleton<MainWindowViewModel>();
_ = services.AddEventBus(e =>
{
e.Options.UseEventPolymorphism = true;
e.Options.UseEventsQueue = true;
e.Options.QueueMode = ProcessingMode.Parallel;
e.UseBackgroundService<DependencyInjectionQueueProcessor>();
e.AddAllConsumers(Assembly.GetExecutingAssembly());
});
}
)
.Build();
/// <summary>
/// Occurs when the application is loading.
/// </summary>
private async void OnStartup(object sender, StartupEventArgs e)
{
await Host.StartAsync();
}
/// <summary>
/// Occurs when the application is closing.
/// </summary>
private async void OnExit(object sender, ExitEventArgs e)
{
await Host.StopAsync();
Host.Dispose();
}
}