Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 67aa254

Browse files
committed
Removing ApplicationServices from HttpContext #466
1 parent 78e90d7 commit 67aa254

File tree

7 files changed

+5
-18
lines changed

7 files changed

+5
-18
lines changed

Diff for: src/Microsoft.AspNet.Http.Abstractions/Extensions/UseMiddlewareExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static IApplicationBuilder UseMiddleware(this IApplicationBuilder app, Ty
7474

7575
return context =>
7676
{
77-
var serviceProvider = context.RequestServices ?? context.ApplicationServices ?? applicationServices;
77+
var serviceProvider = context.RequestServices ?? applicationServices;
7878
if (serviceProvider == null)
7979
{
8080
throw new InvalidOperationException(Resources.FormatException_UseMiddlewareIServiceProviderNotAvailable(nameof(IServiceProvider)));

Diff for: src/Microsoft.AspNet.Http.Abstractions/HttpContext.cs

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ public abstract class HttpContext
5555
/// </summary>
5656
public abstract IDictionary<object, object> Items { get; set; }
5757

58-
/// <summary>
59-
/// Gets or sets the <see cref="IServiceProvider"/> that provides access to the application's service container.
60-
/// </summary>
61-
public abstract IServiceProvider ApplicationServices { get; set; }
62-
6358
/// <summary>
6459
/// Gets or sets the <see cref="IServiceProvider"/> that provides access to the request's service container.
6560
/// </summary>

Diff for: src/Microsoft.AspNet.Http/DefaultHttpContext.cs

-6
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,6 @@ public override IDictionary<object, object> Items
176176
set { ItemsFeature.Items = value; }
177177
}
178178

179-
public override IServiceProvider ApplicationServices
180-
{
181-
get { return ServiceProvidersFeature.ApplicationServices; }
182-
set { ServiceProvidersFeature.ApplicationServices = value; }
183-
}
184-
185179
public override IServiceProvider RequestServices
186180
{
187181
get { return ServiceProvidersFeature.RequestServices; }

Diff for: src/Microsoft.AspNet.Http/Features/IServiceProvidersFeature.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Http.Features.Internal
77
{
88
public interface IServiceProvidersFeature
99
{
10-
IServiceProvider ApplicationServices { get; set; }
1110
IServiceProvider RequestServices { get; set; }
1211
}
1312
}

Diff for: src/Microsoft.AspNet.Http/Features/ServiceProvidersFeature.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Http.Features.Internal
77
{
88
public class ServiceProvidersFeature : IServiceProvidersFeature
99
{
10-
public IServiceProvider ApplicationServices { get; set; }
1110
public IServiceProvider RequestServices { get; set; }
1211
}
1312
}

Diff for: src/Microsoft.AspNet.Owin/OwinExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static IApplicationBuilder UseBuilder(this AddMiddleware app, IServicePro
8686
return builder;
8787
}
8888

89-
private static CreateMiddleware CreateMiddlewareFactory(Func<RequestDelegate, RequestDelegate> middleware, IServiceProvider applicationServices)
89+
private static CreateMiddleware CreateMiddlewareFactory(Func<RequestDelegate, RequestDelegate> middleware, IServiceProvider services)
9090
{
9191
return next =>
9292
{
@@ -110,7 +110,7 @@ private static CreateMiddleware CreateMiddlewareFactory(Func<RequestDelegate, Re
110110
context = new DefaultHttpContext(
111111
new FeatureCollection(
112112
new OwinFeatureCollection(env)));
113-
context.ApplicationServices = applicationServices;
113+
context.RequestServices = services;
114114
}
115115

116116
return app.Invoke(context);

Diff for: test/Microsoft.AspNet.Owin.Tests/OwinExtensionTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void OwinConfigureServiceProviderAddsServices()
3838
serviceProvider = applicationBuilder.ApplicationServices;
3939
applicationBuilder.Run(async context =>
4040
{
41-
fakeService = context.ApplicationServices.GetService<FakeService>();
41+
fakeService = context.RequestServices.GetService<FakeService>();
4242
});
4343
}, new ServiceCollection().AddSingleton(new FakeService()).BuildServiceProvider());
4444

@@ -66,7 +66,7 @@ public void OwinDefaultNoServices()
6666
applicationBuilder.Run(async context =>
6767
{
6868
applicationExecuted = true;
69-
fakeService = context.ApplicationServices.GetService<FakeService>();
69+
fakeService = context.RequestServices.GetService<FakeService>();
7070
});
7171
});
7272

0 commit comments

Comments
 (0)