-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (33 loc) · 1.27 KB
/
Copy pathProgram.cs
File metadata and controls
40 lines (33 loc) · 1.27 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
using Avalonia;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI.Avalonia;
namespace Inlay;
public static class Program
{
private static readonly Lazy<ServiceProvider> PreviewServices = new(CreatePreviewServiceProvider);
[STAThread]
public static void Main(string[] args)
{
using var provider = CreateServiceProvider();
BuildAvaloniaApp(provider).StartWithClassicDesktopLifetime(args);
}
public static AppBuilder BuildAvaloniaApp() => BuildAvaloniaApp(PreviewServices.Value);
private static AppBuilder BuildAvaloniaApp(IServiceProvider services) =>
AppBuilder.Configure(() => new App(services))
.UsePlatformDetect()
.UseReactiveUI(_ => { })
.LogToTrace();
private static ServiceProvider CreateServiceProvider()
{
var services = new ServiceCollection();
services.AddSingleton<ITemplateDocumentService, JsonTemplateDocumentService>();
services.AddSingleton<MainWindowFactory>();
return services.BuildServiceProvider();
}
private static ServiceProvider CreatePreviewServiceProvider()
{
var provider = CreateServiceProvider();
AppDomain.CurrentDomain.ProcessExit += (_, _) => provider.Dispose();
return provider;
}
}