This repository was archived by the owner on Nov 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathRequestLocalizationOptionsExtensions.cs
More file actions
40 lines (35 loc) · 1.78 KB
/
RequestLocalizationOptionsExtensions.cs
File metadata and controls
40 lines (35 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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 Microsoft.AspNetCore.Localization;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extension methods for the <see cref="RequestLocalizationOptions"/>.
/// </summary>
public static class RequestLocalizationOptionsExtensions
{
/// <summary>
/// Adds a new <see cref="RequestCultureProvider"/> to the <see cref="RequestLocalizationOptions.RequestCultureProviders"/>.
/// </summary>
/// <param name="requestLocalizationOptions">The cultures to be added.</param>
/// <param name="requestCultureProvider">The cultures to be added.</param>
/// <returns>The <see cref="RequestLocalizationOptions"/>.</returns>
/// <remarks>This method ensures that <paramref name="requestCultureProvider"/> has priority over other <see cref="RequestCultureProvider"/> instances in <see cref="RequestLocalizationOptions.RequestCultureProviders"/>.</remarks>
public static RequestLocalizationOptions AddInitialRequestCultureProvider(
this RequestLocalizationOptions requestLocalizationOptions,
RequestCultureProvider requestCultureProvider)
{
if (requestLocalizationOptions == null)
{
throw new ArgumentNullException(nameof(requestLocalizationOptions));
}
if (requestCultureProvider == null)
{
throw new ArgumentNullException(nameof(requestCultureProvider));
}
requestLocalizationOptions.RequestCultureProviders.Insert(0, requestCultureProvider);
return requestLocalizationOptions;
}
}
}