diff --git a/samples/RoutingSample.Web/Startup.cs b/samples/RoutingSample.Web/Startup.cs index 46110ee964..7bb2f994c4 100644 --- a/samples/RoutingSample.Web/Startup.cs +++ b/samples/RoutingSample.Web/Startup.cs @@ -15,7 +15,7 @@ namespace RoutingSample.Web { builder.UseServices(services => { - services.Add(RoutingServices.GetDefaultServices()); + services.AddRouting(); }); var endpoint1 = new DelegateRouteEndpoint(async (context) => diff --git a/src/Microsoft.AspNet.Routing/RoutingServices.cs b/src/Microsoft.AspNet.Routing/RoutingServices.cs index f534e0f846..956f97c177 100644 --- a/src/Microsoft.AspNet.Routing/RoutingServices.cs +++ b/src/Microsoft.AspNet.Routing/RoutingServices.cs @@ -1,24 +1,18 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Collections.Generic; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; namespace Microsoft.AspNet.Routing { - public class RoutingServices + public static class RoutingServices { - public static IEnumerable GetDefaultServices() + public static IServiceCollection AddRouting(this IServiceCollection services, IConfiguration config = null) { - return GetDefaultServices(new Configuration()); - } - - public static IEnumerable GetDefaultServices(IConfiguration configuration) - { - var describe = new ServiceDescriber(configuration); - - yield return describe.Transient(); + var describe = new ServiceDescriber(config); + services.TryAdd(describe.Transient()); + return services; } } } diff --git a/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs b/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs index bcbb849b3f..9cc3ad3a0d 100644 --- a/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs @@ -293,7 +293,7 @@ namespace Microsoft.AspNet.Routing.Tests private static IInlineConstraintResolver GetConstraintResolver() { - var services = new ServiceCollection { OptionsServices.GetDefaultServices() }; + var services = new ServiceCollection().AddOptions(); services.Configure(options => options .ConstraintMap diff --git a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs index 9fa3579294..3750eaecc7 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs @@ -1054,7 +1054,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests private static IInlineConstraintResolver GetInlineConstraintResolver() { - var services = new ServiceCollection { OptionsServices.GetDefaultServices() }; + var services = new ServiceCollection().AddOptions(); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); return new DefaultInlineConstraintResolver(serviceProvider, accessor); diff --git a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs index 03bd7bf308..30073881a9 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs @@ -829,7 +829,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests private static IInlineConstraintResolver GetInlineConstraintResolver() { - var services = new ServiceCollection { OptionsServices.GetDefaultServices() }; + var services = new ServiceCollection().AddOptions(); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); return new DefaultInlineConstraintResolver(serviceProvider, accessor); diff --git a/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs b/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs index 2fb88d12da..2db6f5440a 100644 --- a/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs @@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Routing.Tests private static IInlineConstraintResolver GetInlineConstraintResolver() { - var services = new ServiceCollection { OptionsServices.GetDefaultServices() }; + var services = new ServiceCollection().AddOptions(); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); return new DefaultInlineConstraintResolver(serviceProvider, accessor);