зеркало из https://github.com/aspnet/Localization.git
Remove usage of TaskCache
This commit is contained in:
Родитель
ea79aadde2
Коммит
3a29c26c46
|
@ -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>
|
||||
|
|
Загрузка…
Ссылка в новой задаче