mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* touching publish.yml * Moved Examples into ./Examples * Moved Benchmarks into ./Tests * Moved Benchmarks into ./Tests * Moved UICatalog into ./Examples * Moved UICatalog into ./Examples 2 * Moved tests into ./Tests * Updated nuget
This commit is contained in:
42
Examples/UICatalog/ScenarioMetadata.cs
Normal file
42
Examples/UICatalog/ScenarioMetadata.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace UICatalog;
|
||||
|
||||
/// <summary>Defines the metadata (Name and Description) for a <see cref="Scenario"/></summary>
|
||||
[AttributeUsage (AttributeTargets.Class)]
|
||||
public class ScenarioMetadata (string name, string description) : System.Attribute
|
||||
{
|
||||
/// <summary><see cref="Scenario"/> Description</summary>
|
||||
public string Description { get; set; } = description;
|
||||
|
||||
/// <summary>Static helper function to get the <see cref="Scenario"/> Description given a Type</summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDescription (Type t)
|
||||
{
|
||||
if (GetCustomAttributes (t).FirstOrDefault (a => a is ScenarioMetadata) is ScenarioMetadata { } metadata)
|
||||
{
|
||||
return metadata.Description;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>Static helper function to get the <see cref="Scenario"/> Name given a Type</summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetName (Type t)
|
||||
{
|
||||
if (GetCustomAttributes (t).FirstOrDefault (a => a is ScenarioMetadata) is ScenarioMetadata { } metadata)
|
||||
{
|
||||
return metadata.Name;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary><see cref="Scenario"/> Name</summary>
|
||||
public string Name { get; set; } = name;
|
||||
}
|
||||
Reference in New Issue
Block a user