#nullable enable using System; using System.Linq; namespace UICatalog; /// Defines the metadata (Name and Description) for a [AttributeUsage (AttributeTargets.Class)] public class ScenarioMetadata (string name, string description) : System.Attribute { /// Description public string Description { get; set; } = description; /// Static helper function to get the Description given a Type /// /// public static string GetDescription (Type t) { if (GetCustomAttributes (t).FirstOrDefault (a => a is ScenarioMetadata) is ScenarioMetadata { } metadata) { return metadata.Description; } return string.Empty; } /// Static helper function to get the Name given a Type /// /// public static string GetName (Type t) { if (GetCustomAttributes (t).FirstOrDefault (a => a is ScenarioMetadata) is ScenarioMetadata { } metadata) { return metadata.Name; } return string.Empty; } /// Name public string Name { get; set; } = name; }