Improved handling of moonlight plugins during startup, minimized host project code and moved startup handling to core
This commit is contained in:
23
Moonlight.Frontend/StartupHandler.cs
Normal file
23
Moonlight.Frontend/StartupHandler.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
|
||||
namespace Moonlight.Frontend;
|
||||
|
||||
public static class StartupHandler
|
||||
{
|
||||
public static async Task RunAsync(string[] args, MoonlightPlugin[] plugins)
|
||||
{
|
||||
Console.WriteLine($"Starting with: {string.Join(", ", plugins.Select(x => x.GetType().FullName))}");
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
||||
foreach (var plugin in plugins)
|
||||
plugin.PreBuild(builder);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
foreach(var plugin in plugins)
|
||||
plugin.PostBuild(app);
|
||||
|
||||
await app.RunAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user