Alloy.Helpers.CategorizableExtensions.GetThemeCssClassNames C# (CSharp) Метод

GetThemeCssClassNames() публичный статический Метод

Returns the CSS classes (if any) associated with the theme(s) of the content, as decided by its categories
Content's categorization may map to more than one theme. This method assumes there are website categories called "Meet", "Track", and "Plan"
public static GetThemeCssClassNames ( this content ) : string[]
content this
Результат string[]
        public static string[] GetThemeCssClassNames(this ICategorizable content)
        {
            if (content.Category == null)
            {
                return new string[0];
            }

            var cssClasses = new HashSet<string>(); // Although with some overhead, a HashSet allows us to ensure we never add a CSS class more than once
            var categoryRepository = ServiceLocator.Current.GetInstance<CategoryRepository>();

            foreach (var categoryName in content.Category.Select(category => categoryRepository.Get(category).Name.ToLower()))
            {
                switch (categoryName)
                {
                    case "meet":
                        cssClasses.Add("theme1");
                        break;
                    case "track":
                        cssClasses.Add("theme2");
                        break;
                    case "plan":
                        cssClasses.Add("theme3");
                        break;
                }
            }

            return cssClasses.ToArray();
        }
CategorizableExtensions