-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.xaml.cs
41 lines (32 loc) · 1.13 KB
/
App.xaml.cs
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
using Moldinium.Injection;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Windows;
using Moldinium;
namespace SampleApp.Wpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application, ILogger
{
public SampleApp.JobList JobList { get; private set; } = null!;
public Action<String>? Log { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var services = new ServiceCollection();
services.AddSingleton<ILogger>(this);
services.AddSingletonMoldiniumRoot<SampleApp.JobList>(c => c
.SetMode(MoldiniumDefaultMode.TrackingAndNotifyPropertyChanged)
.IdentifyMoldiniumTypes(t => t.IsInterface && !t.Name.StartsWithFollowedByCapital("I"))
);
var serviceProvider = services.BuildServiceProvider();
JobList = serviceProvider.GetRequiredService<SampleApp.JobList>();
}
void ILogger.Log(string message)
{
Log?.Invoke(message);
}
}
}