This commit is contained in:
Hisham Bin Ateya 2017-02-07 21:50:05 +03:00 коммит произвёл Ryan Brandenburg
Родитель d1ee393c72
Коммит 5ac6965dc6
5 изменённых файлов: 0 добавлений и 120 удалений

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

@ -14,8 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{7987
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalizationSample", "samples\LocalizationSample\LocalizationSample.csproj", "{55D9501F-15B9-4339-A0AB-6082850E5FCE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.Globalization.CultureInfoCache", "src\Microsoft.Extensions.Globalization.CultureInfoCache\Microsoft.Extensions.Globalization.CultureInfoCache.csproj", "{F3988D3A-A4C8-4FD7-BAFE-13E0D0A1659A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B723DB83-A670-4BCB-95FB-195361331AD2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.Localization.Tests", "test\Microsoft.Extensions.Localization.Tests\Microsoft.Extensions.Localization.Tests.csproj", "{287AD58D-DF34-4F16-8616-FD78FA1CADF9}"

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

@ -12,7 +12,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Extensions.Globalization.CultureInfoCache\Microsoft.Extensions.Globalization.CultureInfoCache.csproj" />
<ProjectReference Include="..\Microsoft.Extensions.Localization.Abstractions\Microsoft.Extensions.Localization.Abstractions.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="1.2.0-*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="1.2.0-*" />

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

@ -1,68 +0,0 @@
// 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.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Microsoft.Extensions.Globalization
{
/// <summary>
/// Provides read-only cached instances of <see cref="CultureInfo"/>.
/// </summary>
[Obsolete("This type is obsolete and will be removed in a future version.")]
public static class CultureInfoCache
{
private static readonly ConcurrentDictionary<string, CacheEntry> _cache = new ConcurrentDictionary<string, CacheEntry>();
/// <summary>
/// Gets a read-only cached <see cref="CultureInfo"/> for the specified name. Only names that exist in
/// <paramref name="supportedCultures"/> will be used.
/// </summary>
/// <param name="name">The culture name.</param>
/// <param name="supportedCultures">The cultures supported by the application.</param>
/// <returns>
/// A read-only cached <see cref="CultureInfo"/> or <c>null</c> if a match wasn't found in
/// <paramref name="supportedCultures"/>.
/// </returns>
public static CultureInfo GetCultureInfo(string name, IList<CultureInfo> supportedCultures)
{
// Allow only known culture names as this API is called with input from users (HTTP requests) and
// creating CultureInfo objects is expensive and we don't want it to throw either.
if (name == null || supportedCultures == null ||
!supportedCultures.Any(supportedCulture => string.Equals(supportedCulture.Name, name, StringComparison.OrdinalIgnoreCase)))
{
return null;
}
var entry = _cache.GetOrAdd(name, n =>
{
try
{
return new CacheEntry(CultureInfo.ReadOnly(new CultureInfo(n)));
}
catch (CultureNotFoundException)
{
// This can still throw as the list of culture names we have is generated from latest .NET Framework
// on latest Windows and thus contains names that won't be supported on lower framework or OS versions.
// We can just cache the null result in these cases as it's ultimately bound by the list anyway.
return new CacheEntry(cultureInfo: null);
}
});
return entry.CultureInfo;
}
private class CacheEntry
{
public CacheEntry(CultureInfo cultureInfo)
{
CultureInfo = cultureInfo;
}
public CultureInfo CultureInfo { get; }
}
}
}

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

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<Product>Microsoft .NET Extensions</Product>
<Description>Provides cached instances of CultureInfo using a generated list of known culture names for use in scenarios where unbounded CultureInfo creation is undesirable.</Description>
<TargetFramework>netstandard1.1</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>globalization;localization</PackageTags>
</PropertyGroup>
</Project>

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

@ -1,35 +0,0 @@
{
"AssemblyIdentity": "Microsoft.Extensions.Globalization.CultureInfoCache, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
"Types": [
{
"Name": "Microsoft.Extensions.Globalization.CultureInfoCache",
"Visibility": "Public",
"Kind": "Class",
"Abstract": true,
"Static": true,
"Sealed": true,
"ImplementedInterfaces": [],
"Members": [
{
"Kind": "Method",
"Name": "GetCultureInfo",
"Parameters": [
{
"Name": "name",
"Type": "System.String"
},
{
"Name": "supportedCultures",
"Type": "System.Collections.Generic.IList<System.Globalization.CultureInfo>"
}
],
"ReturnType": "System.Globalization.CultureInfo",
"Static": true,
"Visibility": "Public",
"GenericParameter": []
}
],
"GenericParameters": []
}
]
}