public static IServiceCollection AddSendGrid(this IServiceCollection services, IConfiguration configuration) { var config = new SendGridConfiguration(); configuration.Bind(config); services.AddTransient <ISendGridClient>(_ => new SendGridClient(config.ApiKey)); services.AddTransient <ISendGridSender, SendGridSender>(); services.Configure <SendGridConfiguration>(configuration); return(services); }
public SendGridSender(ISendGridClient client, ILogger <SendGridSender> logger, IOptions <SendGridConfiguration> options) { _client = client; _logger = logger; _configuration = options.Value; }