This commit is contained in:
Pranav K 2017-06-08 12:15:51 -07:00
Родитель ea79aadde2
Коммит 3a29c26c46
7 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -17,7 +17,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All"/>
</ItemGroup>
</Project>

Просмотреть файл

@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Localization.Routing
if (culture == null && uiCulture == null)
{
// No values specified for either so no match
return TaskCache<ProviderCultureResult>.DefaultCompletedTask;
return NullProviderCultureResult;
}
if (culture != null && uiCulture == null)

Просмотреть файл

@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Localization
if (acceptLanguageHeader == null || acceptLanguageHeader.Count == 0)
{
return TaskCache<ProviderCultureResult>.DefaultCompletedTask;
return NullProviderCultureResult;
}
var languages = acceptLanguageHeader.AsEnumerable();
@ -49,12 +49,12 @@ namespace Microsoft.AspNetCore.Localization
var orderedLanguages = languages.OrderByDescending(h => h, StringWithQualityHeaderValueComparer.QualityComparer)
.Select(x => x.Value).ToList();
if (orderedLanguages.Any())
if (orderedLanguages.Count > 0)
{
return Task.FromResult(new ProviderCultureResult(orderedLanguages));
}
return TaskCache<ProviderCultureResult>.DefaultCompletedTask;
return NullProviderCultureResult;
}
}
}

Просмотреть файл

@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Localization
if (string.IsNullOrEmpty(cookie))
{
return TaskCache<ProviderCultureResult>.DefaultCompletedTask;
return NullProviderCultureResult;
}
var providerResultCulture = ParseCookieValue(cookie);

Просмотреть файл

@ -18,7 +18,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All"/>
</ItemGroup>
</Project>

Просмотреть файл

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Localization
var request = httpContext.Request;
if (!request.QueryString.HasValue)
{
return TaskCache<ProviderCultureResult>.DefaultCompletedTask;
return NullProviderCultureResult;
}
string queryCulture = null;
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Localization
if (queryCulture == null && queryUICulture == null)
{
// No values specified for either so no match
return TaskCache<ProviderCultureResult>.DefaultCompletedTask;
return NullProviderCultureResult;
}
if (queryCulture != null && queryUICulture == null)

Просмотреть файл

@ -12,6 +12,12 @@ namespace Microsoft.AspNetCore.Localization
/// </summary>
public abstract class RequestCultureProvider : IRequestCultureProvider
{
/// <summary>
/// Result that indicates that this instance of <see cref="RequestCultureProvider" /> could not determine the
/// request culture.
/// </summary>
protected static readonly Task<ProviderCultureResult> NullProviderCultureResult = Task.FromResult(default(ProviderCultureResult));
/// <summary>
/// The current options for the <see cref="RequestLocalizationMiddleware"/>.
/// </summary>