// 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.AspNetCore.Http; namespace Microsoft.AspNetCore.Localization { /// /// Determines the culture information for a request via the configured delegate. /// public class CustomRequestCultureProvider : RequestCultureProvider { private readonly Func> _provider; /// /// Creates a new using the specified delegate. /// /// The provider delegate. public CustomRequestCultureProvider(Func> provider) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } _provider = provider; } /// public override Task DetermineProviderCultureResult(HttpContext httpContext) { if (httpContext == null) { throw new ArgumentNullException(nameof(httpContext)); } return _provider(httpContext); } } }