-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.axaml.cs
50 lines (40 loc) · 1.38 KB
/
App.axaml.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
42
43
44
45
46
47
48
49
50
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using SharpFM.ViewModels;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using System;
using SharpFM.Services;
namespace SharpFM;
public partial class App : Application
{
ILogger logger = LoggerFactory.Create(builder => builder.AddNLog()).CreateLogger<MainWindow>();
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(logger)
};
var services = new ServiceCollection();
services.AddSingleton(x => new FolderService(desktop.MainWindow));
Services = services.BuildServiceProvider();
}
base.OnFrameworkInitializationCompleted();
}
/// <summary>
/// Get a reference to the current app.
/// </summary>
public new static App? Current => Application.Current as App;
/// <summary>
/// Gets the <see cref="IServiceProvider"/> instance to resolve application services.
/// </summary>
public IServiceProvider? Services { get; private set; }
}