public AliyunSmsService( AliyunSmsConfiguration configuration, HttpClient httpClient, ILogger <AliyunSmsService> logger) { _config = configuration; _logger = logger; _httpClient = httpClient; }
public static IServiceCollection AddAliyunSmsService(this IServiceCollection services, AliyunSmsConfiguration smsConfiguration) { if (smsConfiguration == null) { throw new ArgumentNullException(nameof(smsConfiguration)); } services.AddSingleton(smsConfiguration); var registration = services.FirstOrDefault(service => service.ServiceType == typeof(HttpClient)); if (registration == null) { services.AddSingleton <HttpClient>(); } services.AddSingleton <IShortMessageService, AliyunSmsService>(); return(services); }