You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

using CoreAgent.Domain.Interfaces.Network;
using CoreAgent.Domain.Interfaces.System.Command;
using CoreAgent.Infrastructure.Command.Factories;
using CoreAgent.Infrastructure.Services;
using Microsoft.Extensions.DependencyInjection;
namespace CoreAgent.Infrastructure.Extensions.ServiceCollection;
/// <summary>
/// 命令服务扩展方法
/// </summary>
public static class CommandServiceExtensions
{
/// <summary>
/// 添加命令策略服务
/// </summary>
/// <param name="services">服务集合</param>
/// <returns>服务集合</returns>
public static IServiceCollection AddCommandCustomService(this IServiceCollection services)
{
// 注册命令执行器工厂
services.AddSingleton<ISystemCommandExecutorFactory, SystemCommandExecutorFactory>();
// 注册命令执行器
services.AddTransient<ISystemCommandExecutor>(sp =>
{
var factory = sp.GetRequiredService<ISystemCommandExecutorFactory>();
return factory.CreateExecutor();
});
// 注册 ICellularNetworkService
services.AddScoped<ICellularNetworkService, CellularNetworkService>();
return services;
}
}