@@ -11,34 +11,17 @@ namespace Cuiliang.AliyunOssSdk
11
11
public static class OssClientExtensions
12
12
{
13
13
public static IServiceCollection AddOssClient ( this IServiceCollection services ,
14
- Action < OssCredential > optionsAction ,
15
- ClientConfiguration config = null )
14
+ IConfigurationSection ossClientConf , ClientConfiguration config = null )
16
15
{
17
-
18
16
var credential = new OssCredential ( ) ;
19
- optionsAction ? . Invoke ( credential ) ;
17
+ ossClientConf . Bind ( credential ) ;
18
+
20
19
var requestContext = new RequestContext ( credential , config ?? ClientConfiguration . Default ) ;
21
20
22
21
services . AddSingleton < RequestContext > ( requestContext ) ;
23
22
services . AddHttpClient < OssClient > ( ) ;
24
23
25
24
return services ;
26
25
}
27
-
28
- public static IServiceCollection AddOssClient ( this IServiceCollection services ,
29
- IConfigurationSection ossClientConf ,
30
- ClientConfiguration config = null )
31
- {
32
- var ossClientOptions = new OssClientOptions ( ) ;
33
- ossClientConf . Bind ( ossClientOptions ) ;
34
-
35
- return
36
- AddOssClient ( services , options =>
37
- {
38
- options . AccessKeyId = ossClientOptions . AccessKeyId ;
39
- options . AccessKeySecret = ossClientOptions . AccessKeySecret ;
40
- options . SecurityToken = ossClientOptions . SecurityToken ;
41
- } , config ) ;
42
- }
43
26
}
44
27
}
0 commit comments