Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 20848da

Browse files
committed
React to DI changes
1 parent ae23f7c commit 20848da

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/Microsoft.Framework.WebEncoders/EncoderServices.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
65
using Microsoft.Framework.DependencyInjection;
76
using Microsoft.Framework.OptionsModel;
87

98
namespace Microsoft.Framework.WebEncoders
109
{
1110
public static class EncoderServices
1211
{
13-
public static IEnumerable<IServiceDescriptor> GetDefaultServices()
12+
public static IServiceCollection GetDefaultServices()
1413
{
15-
var describe = new ServiceDescriber();
14+
var services = new ServiceCollection();
1615

1716
// Register the default encoders
1817
// We want to call the 'Default' property getters lazily since they perform static caching
19-
yield return describe.Singleton<IHtmlEncoder>(CreateFactory(() => HtmlEncoder.Default, filter => new HtmlEncoder(filter)));
20-
yield return describe.Singleton<IJavaScriptStringEncoder>(CreateFactory(() => JavaScriptStringEncoder.Default, filter => new JavaScriptStringEncoder(filter)));
21-
yield return describe.Singleton<IUrlEncoder>(CreateFactory(() => UrlEncoder.Default, filter => new UrlEncoder(filter)));
18+
services.AddSingleton<IHtmlEncoder>(CreateFactory(() => HtmlEncoder.Default, filter => new HtmlEncoder(filter)));
19+
services.AddSingleton<IJavaScriptStringEncoder>(CreateFactory(() => JavaScriptStringEncoder.Default, filter => new JavaScriptStringEncoder(filter)));
20+
services.AddSingleton<IUrlEncoder>(CreateFactory(() => UrlEncoder.Default, filter => new UrlEncoder(filter)));
21+
22+
return services;
2223
}
2324

2425
private static Func<IServiceProvider, T> CreateFactory<T>(Func<T> defaultFactory, Func<ICodePointFilter, T> customFilterFactory)

test/Microsoft.AspNet.Http.Extensions.Tests/UseWithServicesTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using Xunit;
6-
using Microsoft.AspNet.Builder;
7-
using Microsoft.Framework.DependencyInjection;
8-
using Microsoft.Framework.DependencyInjection.Fallback;
9-
using Microsoft.AspNet.Http.Core;
105
using System.Collections.Generic;
116
using System.Threading.Tasks;
7+
using Microsoft.AspNet.Builder;
8+
using Microsoft.AspNet.Http.Core;
9+
using Microsoft.Framework.DependencyInjection;
10+
using Xunit;
1211

1312
namespace Microsoft.AspNet.Http.Extensions.Tests
1413
{

test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using Xunit;
66
using Microsoft.Framework.DependencyInjection;
7-
using Microsoft.Framework.DependencyInjection.Fallback;
87

98
namespace Microsoft.Framework.WebEncoders
109
{

0 commit comments

Comments
 (0)