private bool IsBaseTheme(string featureId, string themeId) { // determine if the given feature is a base theme of the given theme var availableFeatures = _extensionManager.GetExtensions().Features; var themeFeature = availableFeatures.SingleOrDefault(fd => fd.Id == themeId); while (themeFeature != null && themeFeature.Extension.Manifest.IsTheme()) { var themeExtensionInfo = new ThemeExtensionInfo(themeFeature.Extension); if (!themeExtensionInfo.HasBaseTheme()) { return(false); } if (themeExtensionInfo.IsBaseThemeFeature(featureId)) { return(true); } themeFeature = availableFeatures.SingleOrDefault(fd => fd.Id == themeExtensionInfo.BaseTheme); } return(false); }
private IEnumerable <IExtensionInfo> GetBaseThemes(IExtensionInfo theme, string adminThemeId, IEnumerable <IExtensionInfo> extensions) { if (theme?.Id.Equals(adminThemeId, StringComparison.OrdinalIgnoreCase) ?? false) { return(extensions.Where(e => e.Manifest.IsTheme() && e.Id != adminThemeId)); } else { var list = new List <IExtensionInfo>(); if (theme == null) { return(list); } var themeInfo = new ThemeExtensionInfo(theme); while (true) { if (!themeInfo.HasBaseTheme()) { break; } var baseTheme = extensions.FirstOrDefault(e => themeInfo.IsBaseThemeFeature(e.Id)); if (baseTheme == null || list.Contains(baseTheme)) { break; } list.Add(baseTheme); theme = baseTheme; } return(list); } }