From 20848da93f87d7140e4ff87456f711f7081576eb Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 4 Mar 2015 18:08:36 -0800 Subject: [PATCH] React to DI changes --- .../EncoderServices.cs | 13 +++++++------ .../UseWithServicesTests.cs | 9 ++++----- .../EncoderServiceCollectionExtensionsTests.cs | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.Framework.WebEncoders/EncoderServices.cs b/src/Microsoft.Framework.WebEncoders/EncoderServices.cs index 0f90180228..a19116daf2 100644 --- a/src/Microsoft.Framework.WebEncoders/EncoderServices.cs +++ b/src/Microsoft.Framework.WebEncoders/EncoderServices.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.Framework.DependencyInjection; using Microsoft.Framework.OptionsModel; @@ -10,15 +9,17 @@ namespace Microsoft.Framework.WebEncoders { public static class EncoderServices { - public static IEnumerable GetDefaultServices() + public static IServiceCollection GetDefaultServices() { - var describe = new ServiceDescriber(); + var services = new ServiceCollection(); // Register the default encoders // We want to call the 'Default' property getters lazily since they perform static caching - yield return describe.Singleton(CreateFactory(() => HtmlEncoder.Default, filter => new HtmlEncoder(filter))); - yield return describe.Singleton(CreateFactory(() => JavaScriptStringEncoder.Default, filter => new JavaScriptStringEncoder(filter))); - yield return describe.Singleton(CreateFactory(() => UrlEncoder.Default, filter => new UrlEncoder(filter))); + services.AddSingleton(CreateFactory(() => HtmlEncoder.Default, filter => new HtmlEncoder(filter))); + services.AddSingleton(CreateFactory(() => JavaScriptStringEncoder.Default, filter => new JavaScriptStringEncoder(filter))); + services.AddSingleton(CreateFactory(() => UrlEncoder.Default, filter => new UrlEncoder(filter))); + + return services; } private static Func CreateFactory(Func defaultFactory, Func customFilterFactory) diff --git a/test/Microsoft.AspNet.Http.Extensions.Tests/UseWithServicesTests.cs b/test/Microsoft.AspNet.Http.Extensions.Tests/UseWithServicesTests.cs index d2393592ad..7cf66aa951 100644 --- a/test/Microsoft.AspNet.Http.Extensions.Tests/UseWithServicesTests.cs +++ b/test/Microsoft.AspNet.Http.Extensions.Tests/UseWithServicesTests.cs @@ -2,13 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Xunit; -using Microsoft.AspNet.Builder; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.Fallback; -using Microsoft.AspNet.Http.Core; using System.Collections.Generic; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http.Core; +using Microsoft.Framework.DependencyInjection; +using Xunit; namespace Microsoft.AspNet.Http.Extensions.Tests { diff --git a/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs b/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs index 41ab636a64..d629184281 100644 --- a/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs +++ b/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs @@ -4,7 +4,6 @@ using System; using Xunit; using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.Fallback; namespace Microsoft.Framework.WebEncoders {