Exemplo n.º 1
0
        public override string GetVaryByCustomString(HttpContext context, string custom)
        {
            var parts          = custom.Split(';');
            var varyParts      = new List <string>();
            var contextWrapper = new HttpContextWrapper(context);

            foreach (string part in parts)
            {
                switch (part)
                {
                case "userName":
                    varyParts.Add($"user:{context.User.Identity.Name}");
                    break;

                case "lang":
                    varyParts.Add($"lang:{Locale.DetectCulture(contextWrapper).IetfLanguageTag}");
                    break;

                case "theme":
                    varyParts.Add($"theme:{Theme.DetectTheme(contextWrapper)}");
                    break;
                }
            }

            return(string.Join(";", varyParts.OrderBy(s => s)));
        }
Exemplo n.º 2
0
        protected override void Initialize(RequestContext requestContext)
        {
            CultureInfo ci = Locale.DetectCulture(requestContext.HttpContext);

            CultureInfo.CurrentCulture   = ci;
            CultureInfo.CurrentUICulture = ci;

            ViewBag.Theme = new Theme(Theme.DetectTheme(requestContext.HttpContext));

            base.Initialize(requestContext);
        }