mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-21 22:45:20 +00:00
Add missing extension method overloads
This commit is contained in:
@@ -44,5 +44,98 @@
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="WebApplicationBuilder"/> to extend.</param>
|
||||
/// <param name="args">The command-line arguments passed to the process, forwarded to Electron.</param>
|
||||
/// <param name="onAppReadyCallback">
|
||||
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The same <see cref="WebApplicationBuilder"/> instance to enable fluent configuration.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code language="csharp">
|
||||
/// 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();
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func<string[], Task> onAppReadyCallback)
|
||||
{
|
||||
builder.WebHost.UseElectron(args, onAppReadyCallback);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="WebApplicationBuilder"/> to extend.</param>
|
||||
/// <param name="args">The command-line arguments passed to the process, forwarded to Electron.</param>
|
||||
/// <param name="onAppReadyCallback">
|
||||
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The same <see cref="WebApplicationBuilder"/> instance to enable fluent configuration.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code language="csharp">
|
||||
/// 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();
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func<IServiceProvider, Task> onAppReadyCallback)
|
||||
{
|
||||
builder.WebHost.UseElectron(args, onAppReadyCallback);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="WebApplicationBuilder"/> to extend.</param>
|
||||
/// <param name="args">The command-line arguments passed to the process, forwarded to Electron.</param>
|
||||
/// <param name="onAppReadyCallback">
|
||||
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The same <see cref="WebApplicationBuilder"/> instance to enable fluent configuration.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code language="csharp">
|
||||
/// 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();
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func<IServiceProvider, string[], Task> onAppReadyCallback)
|
||||
{
|
||||
builder.WebHost.UseElectron(args, onAppReadyCallback);
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,144 @@
|
||||
return UseElectronCore(builder, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IWebHostBuilder"/> to extend.</param>
|
||||
/// <param name="args">The command-line arguments passed to the process.</param>
|
||||
/// <param name="onAppReadyCallback">
|
||||
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The same <see cref="IWebHostBuilder"/> instance to enable fluent configuration.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code language="csharp">
|
||||
/// 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();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<string[], Task> onAppReadyCallback)
|
||||
{
|
||||
builder.ConfigureServices(services =>
|
||||
{
|
||||
services.AddSingleton<IAppReadyCallbackResolver>(_ => new AppReadyCallbackResolver(args, onAppReadyCallback));
|
||||
});
|
||||
|
||||
return UseElectronCore(builder, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IWebHostBuilder"/> to extend.</param>
|
||||
/// <param name="args">The command-line arguments passed to the process.</param>
|
||||
/// <param name="onAppReadyCallback">
|
||||
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The same <see cref="IWebHostBuilder"/> instance to enable fluent configuration.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code language="csharp">
|
||||
/// 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();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<IServiceProvider, Task> onAppReadyCallback)
|
||||
{
|
||||
builder.ConfigureServices(services =>
|
||||
{
|
||||
services.AddSingleton<IAppReadyCallbackResolver>(provider => new AppReadyCallbackResolver(provider, onAppReadyCallback));
|
||||
});
|
||||
|
||||
return UseElectronCore(builder, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IWebHostBuilder"/> to extend.</param>
|
||||
/// <param name="args">The command-line arguments passed to the process.</param>
|
||||
/// <param name="onAppReadyCallback">
|
||||
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The same <see cref="IWebHostBuilder"/> instance to enable fluent configuration.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code language="csharp">
|
||||
/// 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();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<IServiceProvider, string[], Task> onAppReadyCallback)
|
||||
{
|
||||
builder.ConfigureServices(services =>
|
||||
{
|
||||
services.AddSingleton<IAppReadyCallbackResolver>(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
|
||||
|
||||
Reference in New Issue
Block a user