Initial commit of new UI c# component

This commit is contained in:
LukeFZ
2025-01-25 15:37:43 +01:00
parent ec76447122
commit cc822b418b
21 changed files with 837 additions and 4 deletions

View File

@@ -0,0 +1,54 @@
using Il2CppInspector.Redux.GUI;
using Microsoft.AspNetCore.SignalR;
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
builder.Services.AddSignalR(config =>
{
#if DEBUG
config.EnableDetailedErrors = true;
#endif
});
builder.Services.Configure<JsonHubProtocolOptions>(options =>
{
options.PayloadSerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.SetIsOriginAllowed(origin => origin.StartsWith("http://localhost") || origin.StartsWith("http://tauri.localhost"))
.AllowAnyHeader()
.WithMethods("GET", "POST")
.AllowCredentials();
});
});
builder.Services.AddSingleton<UiProcessService>();
builder.Services.AddSingleton<IHostedService>(p => p.GetRequiredService<UiProcessService>());
var app = builder.Build();
app.UseCors();
app.MapHub<Il2CppHub>("/il2cpp");
await app.StartAsync();
var serverUrl = app.Urls.First();
var port = new Uri(serverUrl).Port;
#if DEBUG
Console.WriteLine($"Listening on port {port}");
#else
app.Services.GetRequiredService<UiProcessService>().LaunchUiProcess(port);
#endif
await app.WaitForShutdownAsync();