コード例 #1
0
        public async Task Invoke(HttpContext httpContext, IThemeAccessor themeAccessor)
        {
            var theme = await themeAccessor.GetCurrentThemeNameAsync();

            httpContext.Items[ThemeConsts.ThemeKey] = theme;

            await _next(httpContext);
        }
コード例 #2
0
        public IEnumerable <string> ExpandViewLocations(WidgetViewLocationExpanderContext context, IEnumerable <string> locations)
        {
            var themeName = AsyncHelper.RunSync(() => _themeAccessor.GetCurrentThemeNameAsync());

            // source path "/{0}/Views/{1}";
            // theme view path = "/{0}/Themes/{2}/{1}";

            if (!themeName.Equals("default", StringComparison.InvariantCultureIgnoreCase))
            {
                var themeViewLocation = $"/{{0}}/Themes/{themeName}/{{1}}";

                return(new string[] { themeViewLocation }.Concat(locations));
            }

            return(locations);
        }