mirror of
https://github.com/Stone-Red-Code/RemoteExec.git
synced 2026-09-04 09:06:20 +02:00
Improve configuration of RemoteExecutor
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user