Ejemplo n.º 1
0
        internal static CultureInfo GetCultureInfoForUserPreferredLanguageInAppX()
        {
            // If a call to GetCultureInfoForUserPreferredLanguageInAppX() generated a recursive
            // call to itself, return null, since we don't want to stack overflow.  For example,
            // this can happen if some code in this method ends up calling CultureInfo.CurrentCulture
            // (which is common on check'd build because of BCLDebug logging which calls Int32.ToString()).
            // In this case, returning null will mean CultureInfo.CurrentCulture gets the default Win32
            // value, which should be fine.
            if (ts_IsDoingAppXCultureInfoLookup)
            {
                return(null);
            }

            CultureInfo toReturn = null;

            try
            {
                ts_IsDoingAppXCultureInfoLookup = true;

                if (s_WindowsRuntimeResourceManager == null)
                {
                    s_WindowsRuntimeResourceManager = ResourceManager.GetWinRTResourceManager();
                }

                toReturn = s_WindowsRuntimeResourceManager.GlobalResourceContextBestFitCultureInfo;
            }
            finally
            {
                ts_IsDoingAppXCultureInfoLookup = false;
            }

            return(toReturn);
        }
Ejemplo n.º 2
0
        internal static bool SetCultureInfoForUserPreferredLanguageInAppX(CultureInfo ci)
        {
            if (s_WindowsRuntimeResourceManager == null)
            {
                s_WindowsRuntimeResourceManager = ResourceManager.GetWinRTResourceManager();
            }

            return(s_WindowsRuntimeResourceManager.SetGlobalResourceContextDefaultCulture(ci));
        }
Ejemplo n.º 3
0
        internal static CultureInfo GetCultureInfoForUserPreferredLanguageInAppX()
        {
            // If a call to GetCultureInfoForUserPreferredLanguageInAppX() generated a recursive
            // call to itself, return null, since we don't want to stack overflow.  For example,
            // this can happen if some code in this method ends up calling CultureInfo.CurrentCulture
            // (which is common on check'd build because of BCLDebug logging which calls Int32.ToString()).
            // In this case, returning null will mean CultureInfo.CurrentCulture gets the default Win32
            // value, which should be fine.
            if (ts_IsDoingAppXCultureInfoLookup)
            {
                return(null);
            }

            // If running within a compilation process (mscorsvw.exe, for example), it is illegal to
            // load any non-mscorlib assembly for execution. Since WindowsRuntimeResourceManager lives
            // in System.Runtime.WindowsRuntime, caller will need to fall back to default Win32 value,
            // which should be fine because we should only ever need to access FX resources during NGEN.
            // FX resources are always loaded from satellite assemblies - even in AppX processes (see the
            // comments in code:System.Resources.ResourceManager.SetAppXConfiguration for more details).
            if (AppDomain.IsAppXNGen)
            {
                return(null);
            }

            CultureInfo toReturn = null;

            try
            {
                ts_IsDoingAppXCultureInfoLookup = true;

                if (s_WindowsRuntimeResourceManager == null)
                {
                    s_WindowsRuntimeResourceManager = ResourceManager.GetWinRTResourceManager();
                }

                toReturn = s_WindowsRuntimeResourceManager.GlobalResourceContextBestFitCultureInfo;
            }
            finally
            {
                ts_IsDoingAppXCultureInfoLookup = false;
            }

            return(toReturn);
        }
Ejemplo n.º 4
0
        internal static bool SetCultureInfoForUserPreferredLanguageInAppX(CultureInfo ci)
        {
            // If running within a compilation process (mscorsvw.exe, for example), it is illegal to
            // load any non-mscorlib assembly for execution. Since WindowsRuntimeResourceManager lives
            // in System.Runtime.WindowsRuntime, caller will need to fall back to default Win32 value,
            // which should be fine because we should only ever need to access FX resources during NGEN.
            // FX resources are always loaded from satellite assemblies - even in AppX processes (see the
            // comments in code:System.Resources.ResourceManager.SetAppXConfiguration for more details).
            if (AppDomain.IsAppXNGen)
            {
                return(false);
            }

            if (s_WindowsRuntimeResourceManager == null)
            {
                s_WindowsRuntimeResourceManager = ResourceManager.GetWinRTResourceManager();
            }

            return(s_WindowsRuntimeResourceManager.SetGlobalResourceContextDefaultCulture(ci));
        }