diff --git a/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs b/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs
index 0283bea..7a68fd6 100644
--- a/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs
+++ b/src/ElectronNET.AspNet/API/WebApplicationBuilderExtensions.cs
@@ -44,5 +44,98 @@
return builder;
}
+
+ ///
+ /// 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 (processArgs) =>
+ /// {
+ /// // 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;
+ }
+
+ ///
+ /// 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 (serviceProvider) =>
+ /// {
+ /// // 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;
+ }
+
+ ///
+ /// 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 (serviceProvider, processArgs) =>
+ /// {
+ /// // 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
diff --git a/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs b/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs
index e40f232..2812474 100644
--- a/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs
+++ b/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs
@@ -69,6 +69,144 @@
return UseElectronCore(builder, args);
}
+ ///
+ /// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
+ ///
+ /// The to extend.
+ /// The command-line arguments passed to the process.
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ /// using Microsoft.AspNetCore.Hosting;
+ /// using Microsoft.Extensions.Hosting;
+ /// using ElectronNET.API;
+ ///
+ /// public class Program
+ /// {
+ /// public static void Main(string[] args)
+ /// {
+ /// Host.CreateDefaultBuilder(args)
+ /// .ConfigureWebHostDefaults(webBuilder =>
+ /// {
+ /// webBuilder.UseStartup<Startup>();
+ /// webBuilder.UseElectron(args, async (processArgs) =>
+ /// {
+ /// // Create the main browser window or perform other startup tasks.
+ /// });
+ /// })
+ /// .Build()
+ /// .Run();
+ /// }
+ /// }
+ ///
+ ///
+ public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func onAppReadyCallback)
+ {
+ builder.ConfigureServices(services =>
+ {
+ services.AddSingleton(_ => new AppReadyCallbackResolver(args, onAppReadyCallback));
+ });
+
+ return UseElectronCore(builder, args);
+ }
+
+ ///
+ /// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
+ ///
+ /// The to extend.
+ /// The command-line arguments passed to the process.
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ /// using Microsoft.AspNetCore.Hosting;
+ /// using Microsoft.Extensions.Hosting;
+ /// using ElectronNET.API;
+ ///
+ /// public class Program
+ /// {
+ /// public static void Main(string[] args)
+ /// {
+ /// Host.CreateDefaultBuilder(args)
+ /// .ConfigureWebHostDefaults(webBuilder =>
+ /// {
+ /// webBuilder.UseStartup<Startup>();
+ /// webBuilder.UseElectron(args, async (serviceProvider) =>
+ /// {
+ /// // Create the main browser window or perform other startup tasks.
+ /// });
+ /// })
+ /// .Build()
+ /// .Run();
+ /// }
+ /// }
+ ///
+ ///
+ public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func onAppReadyCallback)
+ {
+ builder.ConfigureServices(services =>
+ {
+ services.AddSingleton(provider => new AppReadyCallbackResolver(provider, onAppReadyCallback));
+ });
+
+ return UseElectronCore(builder, args);
+ }
+
+ ///
+ /// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
+ ///
+ /// The to extend.
+ /// The command-line arguments passed to the process.
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ /// using Microsoft.AspNetCore.Hosting;
+ /// using Microsoft.Extensions.Hosting;
+ /// using ElectronNET.API;
+ ///
+ /// public class Program
+ /// {
+ /// public static void Main(string[] args)
+ /// {
+ /// Host.CreateDefaultBuilder(args)
+ /// .ConfigureWebHostDefaults(webBuilder =>
+ /// {
+ /// webBuilder.UseStartup<Startup>();
+ /// webBuilder.UseElectron(args, async (serviceProvider, processArgs) =>
+ /// {
+ /// // Create the main browser window or perform other startup tasks.
+ /// });
+ /// })
+ /// .Build()
+ /// .Run();
+ /// }
+ /// }
+ ///
+ ///
+ public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func onAppReadyCallback)
+ {
+ builder.ConfigureServices(services =>
+ {
+ services.AddSingleton(provider => new AppReadyCallbackResolver(provider, args, onAppReadyCallback));
+ });
+
+ return UseElectronCore(builder, args);
+ }
+
private static IWebHostBuilder UseElectronCore(IWebHostBuilder builder, string[] args)
{
// no matter how this is set - let's unset to prevent Electron not starting as expected