-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (33 loc) · 1.24 KB
/
Program.cs
File metadata and controls
42 lines (33 loc) · 1.24 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
using Microsoft.Extensions.DependencyInjection;
using Terminal.Gui.App;
using Terminal.Gui.Configuration;
namespace CommunityToolkitExample;
public static class Program
{
public static IServiceProvider? Services { get; private set; }
private static async Task Main (string[] args)
{
var smokeTest = args.Length > 0 && args [0] == "--smoke-test";
ConfigurationManager.Enable (ConfigLocations.All);
Services = ConfigureServices ();
using IApplication app = Application.Create ();
app.Init ();
if (smokeTest)
{
using CancellationTokenSource cts = new (TimeSpan.FromSeconds (2));
using LoginView smokeLoginView = Services.GetRequiredService<LoginView> ();
await app.RunAsync (smokeLoginView, cts.Token);
Console.WriteLine ("Smoke test passed.");
return;
}
using LoginView loginView = Services.GetRequiredService<LoginView> ();
app.Run (loginView);
}
private static IServiceProvider ConfigureServices ()
{
ServiceCollection services = new ();
services.AddTransient<LoginView> ();
services.AddTransient<LoginViewModel> ();
return services.BuildServiceProvider ();
}
}