diff --git a/src/Microsoft.AspNet.Routing/RoutingServices.cs b/src/Microsoft.AspNet.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs similarity index 73% rename from src/Microsoft.AspNet.Routing/RoutingServices.cs rename to src/Microsoft.AspNet.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs index ff03f6a8ea..6daf047e22 100644 --- a/src/Microsoft.AspNet.Routing/RoutingServices.cs +++ b/src/Microsoft.AspNet.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs @@ -2,16 +2,20 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text.Encodings.Web; using Microsoft.AspNet.Routing; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection { - public static class RoutingServices + /// + /// Contains extension methods to . + /// + public static class RoutingServiceCollectionExtensions { public static IServiceCollection AddRouting(this IServiceCollection services) { - return AddRouting(services, null); + return AddRouting(services, configureOptions: null); } public static IServiceCollection AddRouting( @@ -20,6 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection { services.AddOptions(); services.TryAddTransient(); + services.TryAddSingleton(UrlEncoder.Default); if (configureOptions != null) { @@ -29,4 +34,4 @@ namespace Microsoft.Extensions.DependencyInjection return services; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Routing/ServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Routing/ServiceCollectionExtensions.cs deleted file mode 100644 index aba0ecd87b..0000000000 --- a/src/Microsoft.AspNet.Routing/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Text.Encodings.Web; -using Microsoft.AspNet.Routing; -using Microsoft.Extensions.DependencyInjection.Extensions; - -namespace Microsoft.Extensions.DependencyInjection -{ - /// - /// Contains extension methods to . - /// - public static class ServiceCollectionExtensions - { - /// - /// Configures a set of for the application. - /// - /// The services available in the application. - /// An action to configure the . - public static void ConfigureRouting( - this IServiceCollection services, - Action setupAction) - { - if (setupAction == null) - { - throw new ArgumentNullException(nameof(setupAction)); - } - - services.TryAddSingleton(UrlEncoder.Default); - services.Configure(setupAction); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Routing.Tests/RouteOptionsTests.cs b/test/Microsoft.AspNet.Routing.Tests/RouteOptionsTests.cs index e2b900c994..e9f874f43a 100644 --- a/test/Microsoft.AspNet.Routing.Tests/RouteOptionsTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/RouteOptionsTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.OptionsModel; @@ -16,10 +15,10 @@ namespace Microsoft.AspNet.Routing.Tests public void ConfigureRouting_ConfiguresOptionsProperly() { // Arrange - var services = new ServiceCollection().AddOptions(); + var services = new ServiceCollection(); // Act - services.ConfigureRouting(options => options.ConstraintMap.Add("foo", typeof(TestRouteConstraint))); + services.AddRouting(options => options.ConstraintMap.Add("foo", typeof(TestRouteConstraint))); var serviceProvider = services.BuildServiceProvider(); // Assert