summaryrefslogtreecommitdiff
path: root/src/mscorlib/corefx/System/Globalization/CultureInfo.Win32.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/corefx/System/Globalization/CultureInfo.Win32.cs')
-rw-r--r--src/mscorlib/corefx/System/Globalization/CultureInfo.Win32.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mscorlib/corefx/System/Globalization/CultureInfo.Win32.cs b/src/mscorlib/corefx/System/Globalization/CultureInfo.Win32.cs
new file mode 100644
index 0000000000..5dacad2fac
--- /dev/null
+++ b/src/mscorlib/corefx/System/Globalization/CultureInfo.Win32.cs
@@ -0,0 +1,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;
+ }
+ }
+} \ No newline at end of file