-
Notifications
You must be signed in to change notification settings - Fork 449
Expand file tree
/
Copy pathFluentEmailSESBuilderExtensions.cs
More file actions
48 lines (43 loc) · 1.96 KB
/
FluentEmailSESBuilderExtensions.cs
File metadata and controls
48 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using FluentEmail.Core.Interfaces;
using FluentEmail.SES;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
namespace Microsoft.Extensions.DependencyInjection
{
public static class FluentEmailSESBuilderExtensions
{
/// <summary>
/// Adds the SES sender services.
/// </summary>
/// <param name="builder">The Fluent Email Service builder.</param>
/// <param name="sesClientOptions">The options to configure the SES client.</param>
/// <returns><see cref="FluentEmailServicesBuilder"/></returns>
public static FluentEmailServicesBuilder AddSESSender(this FluentEmailServicesBuilder builder, FluenEmailSESOptions sesClientOptions)
{
builder.Services.Configure<FluenEmailSESOptions>(options =>
{
options.AccessKeyId = sesClientOptions.AccessKeyId;
options.SecretAccessKey = sesClientOptions.SecretAccessKey;
options.RegionEndpoint = sesClientOptions.RegionEndpoint;
});
builder.Services.TryAddSingleton<ISender, SESSender>();
return builder;
}
/// <summary>
/// Adds the SES sender services.
/// </summary>
/// <param name="builder">The Fluent Email Service builder.</param>
/// <param name="sesClientOptions">The options to configure the SES client.</param>
/// <returns><see cref="FluentEmailServicesBuilder"/></returns>
public static FluentEmailServicesBuilder AddSESSender(this FluentEmailServicesBuilder builder, Action<IServiceProvider, FluenEmailSESOptions> sesClientOptions)
{
builder.Services.AddOptions<FluenEmailSESOptions>()
.Configure<IServiceProvider>((options, provider) =>
{
sesClientOptions(provider, options);
});
builder.Services.TryAddSingleton<ISender, SESSender>();
return builder;
}
}
}