// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.Framework.OptionsModel; namespace Microsoft.AspNet.Cors.Core { /// public class DefaultCorsPolicyProvider : ICorsPolicyProvider { private readonly CorsOptions _options; /// /// Creates a new instance of . /// /// The options configured for the application. public DefaultCorsPolicyProvider(IOptions options) { _options = options.Value; } /// public Task GetPolicyAsync(HttpContext context, string policyName) { if (context == null) { throw new ArgumentNullException(nameof(context)); } return Task.FromResult(_options.GetPolicy(policyName ?? _options.DefaultPolicyName)); } } }