From 99f5febc3b43e394325324fc8b4f74f8dba560f7 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 20 Oct 2015 10:05:22 -0700 Subject: [PATCH] Changing argument type of serverFeatures to IFeatureCollection --- .../Builder/ApplicationBuilderFactory.cs | 5 +++-- .../Builder/IApplicationBuilderFactory.cs | 3 ++- .../Internal/HostingEngine.cs | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.Hosting/Builder/ApplicationBuilderFactory.cs b/src/Microsoft.AspNet.Hosting/Builder/ApplicationBuilderFactory.cs index a5b00f5fbf..eaf8d178d4 100644 --- a/src/Microsoft.AspNet.Hosting/Builder/ApplicationBuilderFactory.cs +++ b/src/Microsoft.AspNet.Hosting/Builder/ApplicationBuilderFactory.cs @@ -4,6 +4,7 @@ using System; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder.Internal; +using Microsoft.AspNet.Http.Features; namespace Microsoft.AspNet.Hosting.Builder { @@ -16,9 +17,9 @@ namespace Microsoft.AspNet.Hosting.Builder _serviceProvider = serviceProvider; } - public IApplicationBuilder CreateBuilder(object server) + public IApplicationBuilder CreateBuilder(IFeatureCollection serverFeatures) { - return new ApplicationBuilder(_serviceProvider, server); + return new ApplicationBuilder(_serviceProvider, serverFeatures); } } } diff --git a/src/Microsoft.AspNet.Hosting/Builder/IApplicationBuilderFactory.cs b/src/Microsoft.AspNet.Hosting/Builder/IApplicationBuilderFactory.cs index ddcf5807a5..00e64a0a2c 100644 --- a/src/Microsoft.AspNet.Hosting/Builder/IApplicationBuilderFactory.cs +++ b/src/Microsoft.AspNet.Hosting/Builder/IApplicationBuilderFactory.cs @@ -2,11 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http.Features; namespace Microsoft.AspNet.Hosting.Builder { public interface IApplicationBuilderFactory { - IApplicationBuilder CreateBuilder(object server); + IApplicationBuilder CreateBuilder(IFeatureCollection serverFeatures); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs index 213b492f16..8c603b6e3c 100644 --- a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs +++ b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Hosting.Internal // Only one of these should be set internal IServerFactory ServerFactory { get; set; } internal string ServerFactoryLocation { get; set; } - private IFeatureCollection _serverInstance; + private IFeatureCollection _serverFeatures; public HostingEngine( IServiceCollection appServices, @@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Hosting.Internal var contextFactory = _applicationServices.GetRequiredService(); var contextAccessor = _applicationServices.GetRequiredService(); var diagnosticSource = _applicationServices.GetRequiredService(); - var server = ServerFactory.Start(_serverInstance, + var server = ServerFactory.Start(_serverFeatures, async features => { var httpContext = contextFactory.CreateHttpContext(features); @@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Hosting.Internal _applicationLifetime.NotifyStarted(); - return new Application(ApplicationServices, _serverInstance, new Disposable(() => + return new Application(ApplicationServices, _serverFeatures, new Disposable(() => { _applicationLifetime.StopApplication(); server.Dispose(); @@ -181,7 +181,7 @@ namespace Microsoft.AspNet.Hosting.Internal EnsureServer(); var builderFactory = _applicationServices.GetRequiredService(); - var builder = builderFactory.CreateBuilder(_serverInstance); + var builder = builderFactory.CreateBuilder(_serverFeatures); builder.ApplicationServices = _applicationServices; var startupFilters = _applicationServices.GetService>(); @@ -247,10 +247,10 @@ namespace Microsoft.AspNet.Hosting.Internal ServerFactory = _applicationServices.GetRequiredService().LoadServerFactory(ServerFactoryLocation); } - if (_serverInstance == null) + if (_serverFeatures == null) { - _serverInstance = ServerFactory.Initialize(_config); - var addresses = _serverInstance?.Get()?.Addresses; + _serverFeatures = ServerFactory.Initialize(_config); + var addresses = _serverFeatures?.Get()?.Addresses; if (addresses != null && !addresses.IsReadOnly) { var port = _config[ServerPort];