Return IServiceCollection from AddWebEncoders extension methods
This commit is contained in:
parent
c5d5ef6788
commit
794d0892ae
|
|
@ -19,8 +19,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
/// to the specified <paramref name="services" />.
|
/// to the specified <paramref name="services" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
||||||
/// <returns>The <see cref="IServiceCollection"/> instance after the encoders have been added.</returns>
|
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
|
||||||
public static void AddWebEncoders(this IServiceCollection services)
|
public static IServiceCollection AddWebEncoders(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
if (services == null)
|
if (services == null)
|
||||||
{
|
{
|
||||||
|
|
@ -37,6 +37,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
CreateFactory(() => JavaScriptEncoder.Default, settings => JavaScriptEncoder.Create(settings)));
|
CreateFactory(() => JavaScriptEncoder.Default, settings => JavaScriptEncoder.Create(settings)));
|
||||||
services.TryAddSingleton(
|
services.TryAddSingleton(
|
||||||
CreateFactory(() => UrlEncoder.Default, settings => UrlEncoder.Create(settings)));
|
CreateFactory(() => UrlEncoder.Default, settings => UrlEncoder.Create(settings)));
|
||||||
|
|
||||||
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -45,7 +47,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
||||||
/// <param name="setupAction">An <see cref="Action{WebEncoderOptions}"/> to configure the provided <see cref="WebEncoderOptions"/>.</param>
|
/// <param name="setupAction">An <see cref="Action{WebEncoderOptions}"/> to configure the provided <see cref="WebEncoderOptions"/>.</param>
|
||||||
public static void AddWebEncoders(this IServiceCollection services, Action<WebEncoderOptions> setupAction)
|
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
|
||||||
|
public static IServiceCollection AddWebEncoders(this IServiceCollection services, Action<WebEncoderOptions> setupAction)
|
||||||
{
|
{
|
||||||
if (services == null)
|
if (services == null)
|
||||||
{
|
{
|
||||||
|
|
@ -59,6 +62,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
services.AddWebEncoders();
|
services.AddWebEncoders();
|
||||||
services.Configure(setupAction);
|
services.Configure(setupAction);
|
||||||
|
|
||||||
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<IServiceProvider, TService> CreateFactory<TService>(
|
private static Func<IServiceProvider, TService> CreateFactory<TService>(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue