PR comments

This commit is contained in:
Praburaj 2015-02-26 10:38:39 -08:00
parent a2eec4f863
commit 435215b542
7 changed files with 16 additions and 16 deletions

View File

@ -11,9 +11,7 @@ namespace Microsoft.AspNet.Hosting.Builder
{
public HttpContext CreateHttpContext(IFeatureCollection featureCollection)
{
var featureObject = featureCollection ?? new FeatureObject(null);
var httpContext = new DefaultHttpContext(new FeatureCollection(featureObject));
return httpContext;
return new DefaultHttpContext(featureCollection);
}
}
}

View File

@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Hosting
{
public class HostingContext
{
public IApplicationLifetime ApplicationLifeTime { get; set; }
public IApplicationLifetime ApplicationLifetime { get; set; }
public IConfiguration Configuration { get; set; }
public IApplicationBuilder Builder { get; set; }
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Hosting
public Action<IApplicationBuilder> ApplicationStartup { get; set; }
public RequestDelegate ApplicationDelegate { get; set; }
public string ServerFactoryAssembly { get; set; }
public string ServerFactoryLocation { get; set; }
public IServerFactory ServerFactory { get; set; }
public IServerInformation Server { get; set; }
}

View File

@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Hosting
InitalizeServerFactory(context);
EnsureApplicationDelegate(context);
var applicationLifetime = (ApplicationLifetime)context.ApplicationLifeTime;
var applicationLifetime = (ApplicationLifetime)context.ApplicationLifetime;
var pipeline = new PipelineInstance(_httpContextFactory, context.ApplicationDelegate, _contextAccessor);
var server = context.ServerFactory.Start(context.Server, pipeline.Invoke);
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Hosting
return;
}
context.ServerFactory = _serverManager.LoadServerFactory(context.ServerFactoryAssembly);
context.ServerFactory = _serverManager.LoadServerFactory(context.ServerFactoryLocation);
}
private void InitalizeServerFactory(HostingContext context)
@ -114,7 +114,9 @@ namespace Microsoft.AspNet.Hosting
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));
}
}

View File

@ -39,13 +39,13 @@ namespace Microsoft.AspNet.Hosting
var appEnv = services.GetRequiredService<IApplicationEnvironment>();
var hostingEnv = services.GetRequiredService<IHostingEnvironment>();
var applicationLifeTime = services.GetRequiredService<IApplicationLifetime>();
var applicationLifetime = services.GetRequiredService<IApplicationLifetime>();
var context = new HostingContext()
{
ApplicationLifeTime = applicationLifeTime,
ApplicationLifetime = applicationLifetime,
Configuration = config,
ServerFactoryAssembly = config.Get("server"), // TODO: Key names
ServerFactoryLocation = config.Get("server"), // TODO: Key names
ApplicationName = config.Get("app") // TODO: Key names
?? appEnv.ApplicationName,
EnvironmentName = hostingEnv.EnvironmentName,

View File

@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Hosting.Startup
{
if (string.IsNullOrEmpty(applicationName))
{
throw new ArgumentNullException("applicationName");
throw new ArgumentException("applicationName");
}
var assembly = Assembly.Load(new AssemblyName(applicationName));

View File

@ -29,12 +29,12 @@ namespace Microsoft.AspNet.TestHost
public TestServer(IConfiguration config, IServiceProvider serviceProvider, Action<IApplicationBuilder> appStartup)
{
var appEnv = serviceProvider.GetRequiredService<IApplicationEnvironment>();
var applicationLifeTime = serviceProvider.GetRequiredService<IApplicationLifetime>();
var applicationLifetime = serviceProvider.GetRequiredService<IApplicationLifetime>();
HostingContext hostContext = new HostingContext()
{
ApplicationName = appEnv.ApplicationName,
ApplicationLifeTime = applicationLifeTime,
ApplicationLifetime = applicationLifetime,
Configuration = config,
ServerFactory = this,
ApplicationStartup = appStartup

View File

@ -35,11 +35,11 @@ namespace Microsoft.AspNet.Hosting
var services = HostingServices.Create().BuildServiceProvider();
var engine = services.GetRequiredService<IHostingEngine>();
var applicationLifeTime = services.GetRequiredService<IApplicationLifetime>();
var applicationLifetime = services.GetRequiredService<IApplicationLifetime>();
var context = new HostingContext
{
ApplicationLifeTime = applicationLifeTime,
ApplicationLifetime = applicationLifetime,
ServerFactory = this,
ApplicationName = "Microsoft.AspNet.Hosting.Tests"
};