示例#1
0
        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);
        }
示例#2
0
 public SendGridSender(ISendGridClient client, ILogger <SendGridSender> logger, IOptions <SendGridConfiguration> options)
 {
     _client        = client;
     _logger        = logger;
     _configuration = options.Value;
 }