mirror of
https://github.com/Stone-Red-Code/RemoteExec.git
synced 2026-09-04 17:16:22 +02:00
26 lines
913 B
C#
26 lines
913 B
C#
// In RemoteExec.Client.DependencyInjection (Extension Project)
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace RemoteExec.Client.DependencyInjection;
|
|
|
|
public static class RemoteExecutorServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddRemoteExecutor(this IServiceCollection services, string[] urls, Action<RemoteExecutorOptions>? configure = null)
|
|
{
|
|
RemoteExecutorOptions options = new RemoteExecutorOptions();
|
|
configure?.Invoke(options);
|
|
|
|
_ = services.AddSingleton(options);
|
|
|
|
_ = services.AddSingleton(sp =>
|
|
{
|
|
RemoteExecutorOptions opt = sp.GetRequiredService<RemoteExecutorOptions>();
|
|
ILogger<RemoteExecutor> logger = sp.GetRequiredService<ILogger<RemoteExecutor>>();
|
|
|
|
return new RemoteExecutor(urls, opt, logger);
|
|
});
|
|
|
|
return services;
|
|
}
|
|
} |