Esempio n. 1
0
        public string GetText(string resourceName, string uiCultureTab = null, params Object[] list)
        {
            var rc = "[not found]";

            try
            {
                if (SupportedCultures != null)
                {
                    if (_rm == null)
                    {
                        var baseName = GetResourcesAsm().GetName().Name + ".Properties.Resources";
                        _rm = new ResourceManager(baseName, GetResourcesAsm());
                    }

                    var cookies = new MxCookies(HttpContextAccessor);
                    if (SupportedCultures.IsSupported(uiCultureTab) == false)
                    {
                        uiCultureTab = SupportedCultures.GetUiCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
                    }
                    var uiCultureInfo = SupportedCultures.GetCultureInfo(uiCultureTab);
                    if (uiCultureInfo != null)
                    {
                        var res = _rm?.GetString(resourceName ?? "NotFound", uiCultureInfo) ?? "[Not Found]";
                        rc = string.Format(uiCultureInfo, res, list);
                    }
                }
            }
            catch (Exception e)
            {
                // ReSharper disable once UnusedVariable
                var msg = e.Message;
                //ignore
            }
            return(rc);
        }
Esempio n. 2
0
        public Instant ParseTimeDate(string timeDate, bool withoutDaylightSaving = false, MxCultureInfo.FormatType formatType = MxCultureInfo.FormatType.DateTime, bool longFormat = false, string cultureTab = null)
        {
            var rc = ExtNodatime.InstantError;

            var cookies = new MxCookies(HttpContextAccessor);

            if (SupportedCultures.IsSupported(cultureTab) == false)
            {
                cultureTab = SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
            }

            if (timeDate.ParseDateTime(DateTimeZoneProviders.Tzdb[SupportedTimeZones.GetTzDbName(cultureTab)], cultureTab, withoutDaylightSaving, formatType, longFormat, out var result))
            {
                rc = result;
            }

            return(rc);
        }
Esempio n. 3
0
        public string InstantToString(Instant timeInstant, string cultureTab = null, bool withoutDaylightSaving = false, MxCultureInfo.FormatType formatType = MxCultureInfo.FormatType.DateTime, bool longFormat = false)
        {
            var rc = "[error]";

            try
            {
                var cookies = new MxCookies(HttpContextAccessor);
                if (SupportedCultures.IsSupported(cultureTab) == false)
                {
                    cultureTab = SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
                }

                rc = timeInstant.ToString(cultureTab, DateTimeZoneProviders.Tzdb[SupportedTimeZones.GetTzDbName(cultureTab)]);
            }
            catch (Exception)
            {
                //ignore
            }
            return(rc);
        }
Esempio n. 4
0
        public string GetUiCultureTab()
        {
            var cookies = new MxCookies(HttpContextAccessor);

            return(SupportedCultures.GetUiCultureTab(cookies.GetValue(MxSupportedCultures.CookieName)));
        }