diff --git a/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs b/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs new file mode 100644 index 0000000..0283bea --- /dev/null +++ b/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs @@ -0,0 +1,48 @@ +namespace ElectronNET.API +{ + using System; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Builder; + + /// + /// Provides extension methods for to enable Electron.NET + /// integration in ASP.NET Core applications (including Razor Pages) using the minimal hosting model. + /// + /// + /// Call this extension during host configuration (for example, in Program.cs) to wire up Electron + /// with any command-line arguments and an optional application-ready callback. + /// + public static class WebApplicationBuilderExtensions + { + /// + /// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback. + /// + /// The to extend. + /// The command-line arguments passed to the process, forwarded to Electron. + /// + /// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization. + /// + /// + /// The same instance to enable fluent configuration. + /// + /// + /// + /// var builder = WebApplication.CreateBuilder(args) + /// .UseElectron(args, async () => + /// { + /// // Create the main browser window or perform other startup tasks. + /// }); + /// + /// var app = builder.Build(); + /// app.MapRazorPages(); + /// app.Run(); + /// + /// + public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func onAppReadyCallback) + { + builder.WebHost.UseElectron(args, onAppReadyCallback); + + return builder; + } + } +} \ No newline at end of file