PR comments
This commit is contained in:
parent
a2eec4f863
commit
435215b542
|
|
@ -11,9 +11,7 @@ namespace Microsoft.AspNet.Hosting.Builder
|
||||||
{
|
{
|
||||||
public HttpContext CreateHttpContext(IFeatureCollection featureCollection)
|
public HttpContext CreateHttpContext(IFeatureCollection featureCollection)
|
||||||
{
|
{
|
||||||
var featureObject = featureCollection ?? new FeatureObject(null);
|
return new DefaultHttpContext(featureCollection);
|
||||||
var httpContext = new DefaultHttpContext(new FeatureCollection(featureObject));
|
|
||||||
return httpContext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
{
|
{
|
||||||
public class HostingContext
|
public class HostingContext
|
||||||
{
|
{
|
||||||
public IApplicationLifetime ApplicationLifeTime { get; set; }
|
public IApplicationLifetime ApplicationLifetime { get; set; }
|
||||||
public IConfiguration Configuration { get; set; }
|
public IConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
public IApplicationBuilder Builder { get; set; }
|
public IApplicationBuilder Builder { get; set; }
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
public Action<IApplicationBuilder> ApplicationStartup { get; set; }
|
public Action<IApplicationBuilder> ApplicationStartup { get; set; }
|
||||||
public RequestDelegate ApplicationDelegate { get; set; }
|
public RequestDelegate ApplicationDelegate { get; set; }
|
||||||
|
|
||||||
public string ServerFactoryAssembly { get; set; }
|
public string ServerFactoryLocation { get; set; }
|
||||||
public IServerFactory ServerFactory { get; set; }
|
public IServerFactory ServerFactory { get; set; }
|
||||||
public IServerInformation Server { get; set; }
|
public IServerInformation Server { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
InitalizeServerFactory(context);
|
InitalizeServerFactory(context);
|
||||||
EnsureApplicationDelegate(context);
|
EnsureApplicationDelegate(context);
|
||||||
|
|
||||||
var applicationLifetime = (ApplicationLifetime)context.ApplicationLifeTime;
|
var applicationLifetime = (ApplicationLifetime)context.ApplicationLifetime;
|
||||||
var pipeline = new PipelineInstance(_httpContextFactory, context.ApplicationDelegate, _contextAccessor);
|
var pipeline = new PipelineInstance(_httpContextFactory, context.ApplicationDelegate, _contextAccessor);
|
||||||
var server = context.ServerFactory.Start(context.Server, pipeline.Invoke);
|
var server = context.ServerFactory.Start(context.Server, pipeline.Invoke);
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.ServerFactory = _serverManager.LoadServerFactory(context.ServerFactoryAssembly);
|
context.ServerFactory = _serverManager.LoadServerFactory(context.ServerFactoryLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitalizeServerFactory(HostingContext context)
|
private void InitalizeServerFactory(HostingContext context)
|
||||||
|
|
@ -114,7 +114,9 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
if (context.ApplicationStartup == null)
|
if (context.ApplicationStartup == null)
|
||||||
{
|
{
|
||||||
throw new Exception(diagnosticMessages.Aggregate("TODO: web application entrypoint not found message", (a, b) => a + "\r\n" + b));
|
throw new ArgumentException(
|
||||||
|
diagnosticMessages.Aggregate("Failed to find an entry point for the web application.", (a, b) => a + "\r\n" + b),
|
||||||
|
nameof(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
var appEnv = services.GetRequiredService<IApplicationEnvironment>();
|
var appEnv = services.GetRequiredService<IApplicationEnvironment>();
|
||||||
var hostingEnv = services.GetRequiredService<IHostingEnvironment>();
|
var hostingEnv = services.GetRequiredService<IHostingEnvironment>();
|
||||||
var applicationLifeTime = services.GetRequiredService<IApplicationLifetime>();
|
var applicationLifetime = services.GetRequiredService<IApplicationLifetime>();
|
||||||
|
|
||||||
var context = new HostingContext()
|
var context = new HostingContext()
|
||||||
{
|
{
|
||||||
ApplicationLifeTime = applicationLifeTime,
|
ApplicationLifetime = applicationLifetime,
|
||||||
Configuration = config,
|
Configuration = config,
|
||||||
ServerFactoryAssembly = config.Get("server"), // TODO: Key names
|
ServerFactoryLocation = config.Get("server"), // TODO: Key names
|
||||||
ApplicationName = config.Get("app") // TODO: Key names
|
ApplicationName = config.Get("app") // TODO: Key names
|
||||||
?? appEnv.ApplicationName,
|
?? appEnv.ApplicationName,
|
||||||
EnvironmentName = hostingEnv.EnvironmentName,
|
EnvironmentName = hostingEnv.EnvironmentName,
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Hosting.Startup
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(applicationName))
|
if (string.IsNullOrEmpty(applicationName))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("applicationName");
|
throw new ArgumentException("applicationName");
|
||||||
}
|
}
|
||||||
|
|
||||||
var assembly = Assembly.Load(new AssemblyName(applicationName));
|
var assembly = Assembly.Load(new AssemblyName(applicationName));
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ namespace Microsoft.AspNet.TestHost
|
||||||
public TestServer(IConfiguration config, IServiceProvider serviceProvider, Action<IApplicationBuilder> appStartup)
|
public TestServer(IConfiguration config, IServiceProvider serviceProvider, Action<IApplicationBuilder> appStartup)
|
||||||
{
|
{
|
||||||
var appEnv = serviceProvider.GetRequiredService<IApplicationEnvironment>();
|
var appEnv = serviceProvider.GetRequiredService<IApplicationEnvironment>();
|
||||||
var applicationLifeTime = serviceProvider.GetRequiredService<IApplicationLifetime>();
|
var applicationLifetime = serviceProvider.GetRequiredService<IApplicationLifetime>();
|
||||||
|
|
||||||
HostingContext hostContext = new HostingContext()
|
HostingContext hostContext = new HostingContext()
|
||||||
{
|
{
|
||||||
ApplicationName = appEnv.ApplicationName,
|
ApplicationName = appEnv.ApplicationName,
|
||||||
ApplicationLifeTime = applicationLifeTime,
|
ApplicationLifetime = applicationLifetime,
|
||||||
Configuration = config,
|
Configuration = config,
|
||||||
ServerFactory = this,
|
ServerFactory = this,
|
||||||
ApplicationStartup = appStartup
|
ApplicationStartup = appStartup
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ namespace Microsoft.AspNet.Hosting
|
||||||
var services = HostingServices.Create().BuildServiceProvider();
|
var services = HostingServices.Create().BuildServiceProvider();
|
||||||
|
|
||||||
var engine = services.GetRequiredService<IHostingEngine>();
|
var engine = services.GetRequiredService<IHostingEngine>();
|
||||||
var applicationLifeTime = services.GetRequiredService<IApplicationLifetime>();
|
var applicationLifetime = services.GetRequiredService<IApplicationLifetime>();
|
||||||
|
|
||||||
var context = new HostingContext
|
var context = new HostingContext
|
||||||
{
|
{
|
||||||
ApplicationLifeTime = applicationLifeTime,
|
ApplicationLifetime = applicationLifetime,
|
||||||
ServerFactory = this,
|
ServerFactory = this,
|
||||||
ApplicationName = "Microsoft.AspNet.Hosting.Tests"
|
ApplicationName = "Microsoft.AspNet.Hosting.Tests"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue