Improve configuration of RemoteExecutor

This commit is contained in:
Stone_Red
2025-12-23 14:43:19 +01:00
parent 64818f735f
commit 5819432c36
16 changed files with 204 additions and 63 deletions
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RemoteExec.Client\RemoteExec.Client.csproj" />
</ItemGroup>
</Project>
@@ -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;
}
}