-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDataProtectorServiceExtensions.cs
More file actions
33 lines (30 loc) · 1.04 KB
/
DataProtectorServiceExtensions.cs
File metadata and controls
33 lines (30 loc) · 1.04 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
/* ===============================================
* 功能描述:AspNetCore.DataProtection.DataProtectionServiceExtensions
* 创 建 者:WeiGe
* 创建日期:9/13/2018 12:09:18 AM
* ===============================================*/
using AspNetCore.DataProtector;
using Microsoft.Extensions.Options;
using System;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
///
/// </summary>
public static class DataProtectorServiceExtensions
{
/// <summary>
///
/// </summary>
/// <param name="services"></param>
/// <param name="action"></param>
/// <returns></returns>
public static IServiceCollection AddDataProtector(this IServiceCollection services, Action<DataProtectorOptions> action = null)
{
services.AddSingleton<IDataProtector, DataProtector>();
services.AddOptions<IOptions<DataProtectorOptions>>();
services.Configure<DataProtectorOptions>(x => action?.Invoke(x));
return services;
}
}
}