@@ -17,45 +17,47 @@ public class WebModule : Module
17
17
protected override void Load ( ContainerBuilder builder )
18
18
{
19
19
var assembly = ThisAssembly ;
20
- builder . RegisterAssemblyTypes ( assembly ) . AsImplementedInterfaces ( ) ;
21
-
22
- builder . RegisterType < HttpContextAccessor > ( ) . As < IHttpContextAccessor > ( ) . SingleInstance ( ) ;
23
- builder . RegisterType < RaygunJobFilter > ( ) . AsSelf ( ) . InstancePerLifetimeScope ( ) ;
24
-
25
- builder . RegisterType < GlobalExceptionFilter > ( ) . AsSelf ( ) . InstancePerLifetimeScope ( ) ;
26
-
27
- builder . Register ( context =>
28
- {
29
- var configurationRoot = context . Resolve < IConfigurationRoot > ( ) ;
30
- var issuerOptions = configurationRoot . GetSection ( "jwtIssuerOptions" ) . Get < JwtIssuerOptions > ( ) ;
31
-
32
- var keyString = issuerOptions . Audience ;
33
- var keyBytes = Encoding . Unicode . GetBytes ( keyString ) ;
34
- var signingKey = new JwtSigningKey ( keyBytes ) ;
35
- return signingKey ;
36
- } )
37
- . AsSelf ( )
38
- . SingleInstance ( ) ;
39
-
40
- builder . Register ( context =>
41
- {
42
- var configurationRoot = context . Resolve < IConfigurationRoot > ( ) ;
43
- var issuerOptions = configurationRoot . GetSection ( "jwtIssuerOptions" ) . Get < JwtIssuerOptions > ( ) ;
44
-
45
- var key = context . Resolve < JwtSigningKey > ( ) ;
46
-
47
- issuerOptions . SigningCredentials = new SigningCredentials ( key , SecurityAlgorithms . HmacSha256Signature ) ;
48
-
49
- return new OptionsWrapper < JwtIssuerOptions > ( issuerOptions ) ;
50
- } ) . As < IOptions < JwtIssuerOptions > > ( ) . InstancePerLifetimeScope ( ) ;
51
-
52
- builder . Register ( context =>
53
- {
54
- var configurationRoot = context . Resolve < IConfigurationRoot > ( ) ;
55
- var key = configurationRoot [ "RaygunSettings:ApiKey" ] ;
56
- var raygunClient = new RaygunClient ( key ) ;
57
- return raygunClient ;
58
- } ) . AsSelf ( ) ;
59
- }
20
+ builder . RegisterAssemblyTypes ( assembly ) . AsImplementedInterfaces ( ) . PreserveExistingDefaults ( ) ;
21
+
22
+ builder . RegisterType < HttpContextAccessor > ( ) . As < IHttpContextAccessor > ( ) . SingleInstance ( ) ;
23
+ builder . RegisterType < RaygunJobFilter > ( ) . AsSelf ( ) . InstancePerLifetimeScope ( ) . PreserveExistingDefaults ( ) ;
24
+
25
+ builder . RegisterType < GlobalExceptionFilter > ( ) . AsSelf ( ) . InstancePerLifetimeScope ( )
26
+ . PreserveExistingDefaults ( ) ;
27
+
28
+ builder . Register ( context =>
29
+ {
30
+ var configurationRoot = context . Resolve < IConfigurationRoot > ( ) ;
31
+ var issuerOptions = configurationRoot . GetSection ( "jwtIssuerOptions" ) . Get < JwtIssuerOptions > ( ) ;
32
+
33
+ var keyString = issuerOptions . Audience ;
34
+ var keyBytes = Encoding . Unicode . GetBytes ( keyString ) ;
35
+ var signingKey = new JwtSigningKey ( keyBytes ) ;
36
+ return signingKey ;
37
+ } )
38
+ . AsSelf ( )
39
+ . SingleInstance ( )
40
+ . PreserveExistingDefaults ( ) ;
41
+
42
+ builder . Register ( context =>
43
+ {
44
+ var configurationRoot = context . Resolve < IConfigurationRoot > ( ) ;
45
+ var issuerOptions = configurationRoot . GetSection ( "jwtIssuerOptions" ) . Get < JwtIssuerOptions > ( ) ;
46
+
47
+ var key = context . Resolve < JwtSigningKey > ( ) ;
48
+
49
+ issuerOptions . SigningCredentials = new SigningCredentials ( key , SecurityAlgorithms . HmacSha256Signature ) ;
50
+
51
+ return new OptionsWrapper < JwtIssuerOptions > ( issuerOptions ) ;
52
+ } ) . As < IOptions < JwtIssuerOptions > > ( ) . InstancePerLifetimeScope ( ) . PreserveExistingDefaults ( ) ;
53
+
54
+ builder . Register ( context =>
55
+ {
56
+ var configurationRoot = context . Resolve < IConfigurationRoot > ( ) ;
57
+ var key = configurationRoot [ "RaygunSettings:ApiKey" ] ;
58
+ var raygunClient = new RaygunClient ( key ) ;
59
+ return raygunClient ;
60
+ } ) . AsSelf ( ) . PreserveExistingDefaults ( ) ;
61
+ }
60
62
}
61
63
}
0 commit comments