Application: Allowing the app to be restarted

This commit is contained in:
Zoe Roux
2021-08-23 21:09:49 +02:00
parent d5e1d4f003
commit 4daa1eb28d
15 changed files with 322 additions and 239 deletions
+6 -18
View File
@@ -1,8 +1,5 @@
using System;
using System.Threading.Tasks;
using Autofac;
using Microsoft.Extensions.Hosting;
using Microsoft.Win32;
namespace Kyoo.WindowsHost
{
@@ -13,22 +10,13 @@ namespace Kyoo.WindowsHost
/// It adds a system trait for windows and since the host is build as a windows executable instead of a console
/// app, the console is not showed.
/// </summary>
public static async Task Main(string[] args)
public static Task Main(string[] args)
{
object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null)
?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null);
if (dataDir is string data)
Environment.SetEnvironmentVariable("KYOO_DATA_DIR", data);
Kyoo.Program.SetupDataDir(args);
IHost host = Kyoo.Program.CreateWebHostBuilder(args)
.ConfigureContainer<ContainerBuilder>(builder =>
{
builder.RegisterType<SystemTrait>().As<IStartable>().SingleInstance();
})
.Build();
await Kyoo.Program.StartWithHost(host);
Application application = new();
return application.Start(args, builder =>
{
builder.RegisterType<SystemTrait>().As<IStartable>().SingleInstance();
});
}
}
}