An `ObjectPoolProvider` is always registered

- react to aspnet/Hosting/pull#673
This commit is contained in:
Doug Bunting 2016-03-24 15:41:16 -07:00
parent 7399cc8957
commit 39b4f6fe53
4 changed files with 7 additions and 2 deletions

View File

@ -28,7 +28,6 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddTransient<IInlineConstraintResolver, DefaultInlineConstraintResolver>();
services.TryAddSingleton(UrlEncoder.Default);
services.TryAddSingleton<ObjectPoolProvider>(new DefaultObjectPoolProvider());
services.TryAddSingleton<ObjectPool<UriBuildingContext>>(s =>
{
var provider = s.GetRequiredService<ObjectPoolProvider>();

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ObjectPool;
using Moq;
using Xunit;
@ -128,6 +128,7 @@ namespace Microsoft.AspNetCore.Routing
private static IServiceProvider CreateServices()
{
var services = new ServiceCollection();
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddOptions();
services.AddRouting();
services.AddLogging();

View File

@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options;
using Moq;
using Xunit;
@ -528,6 +529,7 @@ namespace Microsoft.AspNetCore.Routing
var request = new Mock<HttpRequest>(MockBehavior.Strict);
var services = new ServiceCollection();
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddOptions();
services.AddRouting();
if (options != null)
@ -549,6 +551,7 @@ namespace Microsoft.AspNetCore.Routing
{
var services = new ServiceCollection();
services.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance);
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddOptions();
services.AddRouting();
if (options != null)

View File

@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.ObjectPool;
using Moq;
using Xunit;
@ -1383,6 +1384,7 @@ namespace Microsoft.AspNetCore.Routing
{
var services = new ServiceCollection();
services.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance);
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddRouting();
var context = new DefaultHttpContext