@@ -132,11 +132,6 @@ public static IAppBuilder UseAutofacLifetimeScopeInjector(this IAppBuilder app,
132
132
throw new ArgumentNullException ( "container" ) ;
133
133
}
134
134
135
- if ( app . Properties . ContainsKey ( InjectorRegisteredKey ) )
136
- {
137
- return app ;
138
- }
139
-
140
135
return app . RegisterAutofacLifetimeScopeInjector ( container ) ;
141
136
}
142
137
@@ -189,11 +184,6 @@ public static IAppBuilder UseAutofacMiddleware(this IAppBuilder app, ILifetimeSc
189
184
throw new ArgumentNullException ( "container" ) ;
190
185
}
191
186
192
- if ( app . Properties . ContainsKey ( InjectorRegisteredKey ) )
193
- {
194
- return app ;
195
- }
196
-
197
187
return app
198
188
. RegisterAutofacLifetimeScopeInjector ( container )
199
189
. UseAllMiddlewareRegisteredInContainer ( container ) ;
@@ -254,16 +244,16 @@ public static IAppBuilder UseMiddlewareFromContainer<T>(this IAppBuilder app)
254
244
private static IAppBuilder RegisterAutofacLifetimeScopeInjector ( this IAppBuilder app , ILifetimeScope container )
255
245
{
256
246
app . Use ( async ( context , next ) =>
257
- {
258
- using ( var lifetimeScope = container . BeginLifetimeScope ( MatchingScopeLifetimeTags . RequestLifetimeScopeTag ,
247
+ {
248
+ using ( var lifetimeScope = container . BeginLifetimeScope ( MatchingScopeLifetimeTags . RequestLifetimeScopeTag ,
259
249
b => b . RegisterInstance ( context ) . As < IOwinContext > ( ) ) )
260
- {
261
- context . Set ( Constants . OwinLifetimeScopeKey , lifetimeScope ) ;
262
- await next ( ) ;
263
- }
264
- } ) ;
250
+ {
251
+ context . Set ( Constants . OwinLifetimeScopeKey , lifetimeScope ) ;
252
+ await next ( ) ;
253
+ }
254
+ } ) ;
265
255
266
- app . Properties . Add ( InjectorRegisteredKey , true ) ;
256
+ app . Properties [ InjectorRegisteredKey ] = true ;
267
257
return app ;
268
258
}
269
259
0 commit comments