Removing ApplicationServices from HttpContext #466
This commit is contained in:
parent
78e90d7f04
commit
67aa2546a8
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
|
|
||||||
return context =>
|
return context =>
|
||||||
{
|
{
|
||||||
var serviceProvider = context.RequestServices ?? context.ApplicationServices ?? applicationServices;
|
var serviceProvider = context.RequestServices ?? applicationServices;
|
||||||
if (serviceProvider == null)
|
if (serviceProvider == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(Resources.FormatException_UseMiddlewareIServiceProviderNotAvailable(nameof(IServiceProvider)));
|
throw new InvalidOperationException(Resources.FormatException_UseMiddlewareIServiceProviderNotAvailable(nameof(IServiceProvider)));
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,6 @@ namespace Microsoft.AspNet.Http
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract IDictionary<object, object> Items { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="IServiceProvider"/> that provides access to the request's service container.
|
/// Gets or sets the <see cref="IServiceProvider"/> that provides access to the request's service container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -176,12 +176,6 @@ namespace Microsoft.AspNet.Http.Internal
|
||||||
set { ItemsFeature.Items = value; }
|
set { ItemsFeature.Items = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IServiceProvider ApplicationServices
|
|
||||||
{
|
|
||||||
get { return ServiceProvidersFeature.ApplicationServices; }
|
|
||||||
set { ServiceProvidersFeature.ApplicationServices = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IServiceProvider RequestServices
|
public override IServiceProvider RequestServices
|
||||||
{
|
{
|
||||||
get { return ServiceProvidersFeature.RequestServices; }
|
get { return ServiceProvidersFeature.RequestServices; }
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Http.Features.Internal
|
||||||
{
|
{
|
||||||
public interface IServiceProvidersFeature
|
public interface IServiceProvidersFeature
|
||||||
{
|
{
|
||||||
IServiceProvider ApplicationServices { get; set; }
|
|
||||||
IServiceProvider RequestServices { get; set; }
|
IServiceProvider RequestServices { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Http.Features.Internal
|
||||||
{
|
{
|
||||||
public class ServiceProvidersFeature : IServiceProvidersFeature
|
public class ServiceProvidersFeature : IServiceProvidersFeature
|
||||||
{
|
{
|
||||||
public IServiceProvider ApplicationServices { get; set; }
|
|
||||||
public IServiceProvider RequestServices { get; set; }
|
public IServiceProvider RequestServices { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
return 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 =>
|
return next =>
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
context = new DefaultHttpContext(
|
context = new DefaultHttpContext(
|
||||||
new FeatureCollection(
|
new FeatureCollection(
|
||||||
new OwinFeatureCollection(env)));
|
new OwinFeatureCollection(env)));
|
||||||
context.ApplicationServices = applicationServices;
|
context.RequestServices = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.Invoke(context);
|
return app.Invoke(context);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Owin
|
||||||
serviceProvider = applicationBuilder.ApplicationServices;
|
serviceProvider = applicationBuilder.ApplicationServices;
|
||||||
applicationBuilder.Run(async context =>
|
applicationBuilder.Run(async context =>
|
||||||
{
|
{
|
||||||
fakeService = context.ApplicationServices.GetService<FakeService>();
|
fakeService = context.RequestServices.GetService<FakeService>();
|
||||||
});
|
});
|
||||||
}, new ServiceCollection().AddSingleton(new FakeService()).BuildServiceProvider());
|
}, new ServiceCollection().AddSingleton(new FakeService()).BuildServiceProvider());
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Owin
|
||||||
applicationBuilder.Run(async context =>
|
applicationBuilder.Run(async context =>
|
||||||
{
|
{
|
||||||
applicationExecuted = true;
|
applicationExecuted = true;
|
||||||
fakeService = context.ApplicationServices.GetService<FakeService>();
|
fakeService = context.RequestServices.GetService<FakeService>();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue