blob: 5dacad2fac051bc0e48cd7ff31a1c7f81ed68bfb (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Internal.Runtime.Augments;
namespace System.Globalization
{
public partial class CultureInfo : IFormatProvider
{
/// <summary>
/// Gets the default user culture from WinRT, if available.
/// </summary>
/// <remarks>
/// This method may return null, if there is no default user culture or if WinRT isn't available.
/// </remarks>
private static CultureInfo GetUserDefaultCultureCacheOverride()
{
WinRTInteropCallbacks callbacks = WinRTInterop.UnsafeCallbacks;
if (callbacks != null && callbacks.IsAppxModel())
{
return (CultureInfo)callbacks.GetUserDefaultCulture();
}
return null;
}
private static CultureInfo GetUserDefaultCulture()
{
const uint LOCALE_SNAME = 0x0000005c;
const string LOCALE_NAME_USER_DEFAULT = null;
const string LOCALE_NAME_SYSTEM_DEFAULT = "!x-sys-default-locale";
string strDefault = Interop.mincore.GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME);
if (strDefault == null)
{
strDefault = Interop.mincore.GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME);
if (strDefault == null)
{
// If system default doesn't work, use invariant
return CultureInfo.InvariantCulture;
}
}
CultureInfo temp = GetCultureByName(strDefault, true);
temp.m_isReadOnly = true;
return temp;
}
}
}
|