// 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.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Microsoft.AspNet.Localization
{
///
/// Specifies options for the .
///
public class RequestLocalizationMiddlewareOptions
{
///
/// Creates a new with default values.
///
public RequestLocalizationMiddlewareOptions()
{
DefaultRequestCulture = new RequestCulture(CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture);
RequestCultureStrategies = new List
{
new QueryStringRequestCultureStrategy(),
new CookieRequestCultureStrategy(),
new AcceptLanguageHeaderRequestCultureStrategy { MaximumAcceptLanguageHeaderValuesToTry = MaximumAcceptLanguageHeaderValuesToTry }
};
}
///
/// The maximum number of values in the Accept-Language header to attempt to create a
/// from for the current request.
/// Defaults to 3.
///
public int MaximumAcceptLanguageHeaderValuesToTry { get; set; } = 3;
///
/// The default to use. This value will be used if none of the configured
/// options result in a non-null result.
/// Defaults to set to
/// and set to .
///
public RequestCulture DefaultRequestCulture { get; set; }
///
/// The cultures supported by the application. If this value is non-null, the
/// will only set the current request culture to an entry in this
/// list. A value of null means all cultures are supported.
/// Defaults to null.
///
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Improves usability")]
public IList SupportedCultures { get; set; }
///
/// The UI cultures supported by the application. If this value is non-null, the
/// will only set the current request culture to an entry in this
/// list. A value of null means all cultures are supported.
/// Defaults to null.
///
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Improves usability")]
public IList SupportedUICultures { get; set; }
///
/// An ordered list of strategies used to determine a request's culture information. The first strategy that
/// returns a non-null result for a given request will be used.
/// Defaults to the following:
///
///
///
///
///
///
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Improves usability")]
public IList RequestCultureStrategies { get; set; }
}
}