diff --git a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs
index 6bb7c79d85..a37681f8d4 100644
--- a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs
+++ b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs
@@ -8,49 +8,46 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection
{
///
- /// The extensions for enabling CORS support.
+ /// Extension methods for setting up cross-origin resource sharing services in an .
///
public static class CorsServiceCollectionExtensions
{
///
- /// Add services needed to support CORS to the given .
+ /// Adds cross-origin resource sharing services to the specified .
///
- /// The service collection to which CORS services are added.
- /// The updated .
- public static IServiceCollection AddCors(this IServiceCollection serviceCollection)
+ /// The to add services to.
+ public static void AddCors(this IServiceCollection services)
{
- if (serviceCollection == null)
+ if (services == null)
{
- throw new ArgumentNullException(nameof(serviceCollection));
+ throw new ArgumentNullException(nameof(services));
}
-
- serviceCollection.TryAdd(ServiceDescriptor.Transient());
- serviceCollection.TryAdd(ServiceDescriptor.Transient());
- return serviceCollection;
+
+ services.AddOptions();
+
+ services.TryAdd(ServiceDescriptor.Transient());
+ services.TryAdd(ServiceDescriptor.Transient());
}
///
- /// Add services needed to support CORS to the given .
+ /// Adds cross-origin resource sharing services to the specified .
///
- /// The service collection to which CORS services are added.
- /// A delegate which is run to configure the services.
- /// The updated .
- public static IServiceCollection AddCors(
- this IServiceCollection serviceCollection,
- Action configure)
+ /// The to add services to.
+ /// An to configure the provided .
+ public static void AddCors(this IServiceCollection services, Action setupAction)
{
- if (serviceCollection == null)
+ if (services == null)
{
- throw new ArgumentNullException(nameof(serviceCollection));
+ throw new ArgumentNullException(nameof(services));
}
- if (configure == null)
+ if (setupAction == null)
{
- throw new ArgumentNullException(nameof(configure));
+ throw new ArgumentNullException(nameof(setupAction));
}
- serviceCollection.Configure(configure);
- return serviceCollection.AddCors();
+ services.AddCors();
+ services.Configure(setupAction);
}
}
}
\ No newline at end of file