#nullable enable using System; using System.Collections.Generic; using System.Linq; namespace UICatalog; /// Defines the category names used to categorize a [AttributeUsage (AttributeTargets.Class, AllowMultiple = true)] public class ScenarioCategory (string name) : System.Attribute { /// Static helper function to get the Categories given a Type /// /// list of category names public static List GetCategories (Type t) { return GetCustomAttributes (t) .ToList () .Where (a => a is ScenarioCategory) .Select (a => ((ScenarioCategory)a).Name) .ToList (); } /// Static helper function to get the Name given a Type /// /// Name of the category public static string GetName (Type t) { if (GetCustomAttributes (t).FirstOrDefault (a => a is ScenarioMetadata) is ScenarioMetadata { } metadata) { return metadata.Name; } return string.Empty; } /// Category Name public string Name { get; set; } = name; }