Return IServiceCollection from AddAntiforgery extension methods

This commit is contained in:
jacalvar 2016-03-28 14:59:08 -07:00
parent 0c81df8591
commit 0bc42a9b21
1 changed files with 7 additions and 2 deletions

View File

@ -19,7 +19,8 @@ namespace Microsoft.Extensions.DependencyInjection
/// Adds antiforgery services to the specified <see cref="IServiceCollection" />. /// Adds antiforgery services to the specified <see cref="IServiceCollection" />.
/// </summary> /// </summary>
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> /// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
public static void AddAntiforgery(this IServiceCollection services) /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
public static IServiceCollection AddAntiforgery(this IServiceCollection services)
{ {
if (services == null) if (services == null)
{ {
@ -45,6 +46,8 @@ namespace Microsoft.Extensions.DependencyInjection
var policy = new AntiforgerySerializationContextPooledObjectPolicy(); var policy = new AntiforgerySerializationContextPooledObjectPolicy();
return provider.Create(policy); return provider.Create(policy);
}); });
return services;
} }
/// <summary> /// <summary>
@ -52,7 +55,8 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary> /// </summary>
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> /// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
/// <param name="setupAction">An <see cref="Action{AntiforgeryOptions}"/> to configure the provided <see cref="AntiforgeryOptions"/>.</param> /// <param name="setupAction">An <see cref="Action{AntiforgeryOptions}"/> to configure the provided <see cref="AntiforgeryOptions"/>.</param>
public static void AddAntiforgery(this IServiceCollection services, Action<AntiforgeryOptions> setupAction) /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
public static IServiceCollection AddAntiforgery(this IServiceCollection services, Action<AntiforgeryOptions> setupAction)
{ {
if (services == null) if (services == null)
{ {
@ -66,6 +70,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddAntiforgery(); services.AddAntiforgery();
services.Configure(setupAction); services.Configure(setupAction);
return services;
} }
} }
} }