public void OnResultExecuting(ResultExecutingContext filterContext) { if (filterContext.Result as ViewResult == null) { return; } var previewThemeName = _previewTheme.GetPreviewTheme(); if (string.IsNullOrEmpty(previewThemeName)) { return; } var installedThemes = _featureManager.GetEnabledFeatures() .Select(x => x.Extension) .Where(x => DefaultExtensionTypes.IsTheme(x.ExtensionType)) .Distinct(); var themeListItems = installedThemes .Select(theme => new SelectListItem { Text = theme.Name, Value = theme.Id, Selected = theme.Id == previewThemeName }) .ToList(); _workContextAccessor.GetContext(filterContext).Layout.Zones["Body"].Add(_shapeFactory.ThemePreview(Themes: themeListItems), ":before"); }
public ThemeSelectorResult GetTheme(RequestContext context) { var previewThemeName = _previewTheme.GetPreviewTheme(); return(string.IsNullOrEmpty(previewThemeName) ? null : new ThemeSelectorResult { Priority = 90, ThemeName = previewThemeName }); }