Removing ApplicationServices from HttpContext #466

This commit is contained in:
John Luo 2015-11-19 09:34:38 -08:00
parent 78e90d7f04
commit 67aa2546a8
7 changed files with 5 additions and 18 deletions

View File

@ -74,7 +74,7 @@ namespace Microsoft.AspNet.Builder
return context =>
{
var serviceProvider = context.RequestServices ?? context.ApplicationServices ?? applicationServices;
var serviceProvider = context.RequestServices ?? applicationServices;
if (serviceProvider == null)
{
throw new InvalidOperationException(Resources.FormatException_UseMiddlewareIServiceProviderNotAvailable(nameof(IServiceProvider)));

View File

@ -55,11 +55,6 @@ namespace Microsoft.AspNet.Http
/// </summary>
public abstract IDictionary<object, object> Items { get; set; }
/// <summary>
/// Gets or sets the <see cref="IServiceProvider"/> that provides access to the application's service container.
/// </summary>
public abstract IServiceProvider ApplicationServices { get; set; }
/// <summary>
/// Gets or sets the <see cref="IServiceProvider"/> that provides access to the request's service container.
/// </summary>

View File

@ -176,12 +176,6 @@ namespace Microsoft.AspNet.Http.Internal
set { ItemsFeature.Items = value; }
}
public override IServiceProvider ApplicationServices
{
get { return ServiceProvidersFeature.ApplicationServices; }
set { ServiceProvidersFeature.ApplicationServices = value; }
}
public override IServiceProvider RequestServices
{
get { return ServiceProvidersFeature.RequestServices; }

View File

@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Http.Features.Internal
{
public interface IServiceProvidersFeature
{
IServiceProvider ApplicationServices { get; set; }
IServiceProvider RequestServices { get; set; }
}
}

View File

@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Http.Features.Internal
{
public class ServiceProvidersFeature : IServiceProvidersFeature
{
public IServiceProvider ApplicationServices { get; set; }
public IServiceProvider RequestServices { get; set; }
}
}

View File

@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Builder
return builder;
}
private static CreateMiddleware CreateMiddlewareFactory(Func<RequestDelegate, RequestDelegate> middleware, IServiceProvider applicationServices)
private static CreateMiddleware CreateMiddlewareFactory(Func<RequestDelegate, RequestDelegate> middleware, IServiceProvider services)
{
return next =>
{
@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Builder
context = new DefaultHttpContext(
new FeatureCollection(
new OwinFeatureCollection(env)));
context.ApplicationServices = applicationServices;
context.RequestServices = services;
}
return app.Invoke(context);

View File

@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Owin
serviceProvider = applicationBuilder.ApplicationServices;
applicationBuilder.Run(async context =>
{
fakeService = context.ApplicationServices.GetService<FakeService>();
fakeService = context.RequestServices.GetService<FakeService>();
});
}, new ServiceCollection().AddSingleton(new FakeService()).BuildServiceProvider());
@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Owin
applicationBuilder.Run(async context =>
{
applicationExecuted = true;
fakeService = context.ApplicationServices.GetService<FakeService>();
fakeService = context.RequestServices.GetService<FakeService>();
});
});