From 7f1024aac0174e353b50624b5ece845805d1e115 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 4 Nov 2014 12:32:24 -0800 Subject: [PATCH] Unify ConfigureServices to take IServiceCollection with Options --- src/Microsoft.AspNet.Hosting/Startup/StartupLoader.cs | 8 ++++---- test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Hosting/Startup/StartupLoader.cs b/src/Microsoft.AspNet.Hosting/Startup/StartupLoader.cs index 376ba3a07f..1c6b2eb98a 100644 --- a/src/Microsoft.AspNet.Hosting/Startup/StartupLoader.cs +++ b/src/Microsoft.AspNet.Hosting/Startup/StartupLoader.cs @@ -151,17 +151,17 @@ namespace Microsoft.AspNet.Hosting.Startup { if (servicesMethod != null) { + var services = new ServiceCollection(); + services.Add(OptionsServices.GetDefaultServices()); if (servicesMethod.ReturnType == typeof(IServiceProvider)) { - // IServiceProvider ConfigureServices() - builder.ApplicationServices = (Invoke(servicesMethod, instance, builder) as IServiceProvider) + // IServiceProvider ConfigureServices(IServiceCollection) + builder.ApplicationServices = (Invoke(servicesMethod, instance, builder, services) as IServiceProvider) ?? builder.ApplicationServices; } else { // void ConfigureServices(IServiceCollection) - var services = new ServiceCollection(); - services.Add(OptionsServices.GetDefaultServices()); Invoke(servicesMethod, instance, builder, services); if (builder != null) { diff --git a/test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs b/test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs index dab52127bd..5a85b82357 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs @@ -69,10 +69,8 @@ namespace Microsoft.AspNet.Hosting.Fakes return null; } - public IServiceProvider ConfigureProviderServices() + public IServiceProvider ConfigureProviderServices(IServiceCollection services) { - var services = new ServiceCollection(); - services.Add(OptionsServices.GetDefaultServices()); services.Configure(o => { o.Configured = true;