2024-08-01 19:53:28 +00:00
|
|
|
namespace AIStudio.Tools;
|
|
|
|
|
|
|
|
public sealed class Process<T> where T : struct, Enum
|
|
|
|
{
|
|
|
|
public static readonly Process<T> INSTANCE = new();
|
|
|
|
|
|
|
|
private readonly Dictionary<T, ProcessStepValue> stepsData = [];
|
|
|
|
private readonly int min = int.MaxValue;
|
|
|
|
private readonly int max = int.MinValue;
|
|
|
|
private readonly string[] labels;
|
|
|
|
|
|
|
|
private Process()
|
|
|
|
{
|
|
|
|
var values = Enum.GetValues<T>();
|
|
|
|
this.labels = new string[values.Length];
|
|
|
|
|
|
|
|
for (var i = 0; i < values.Length; i++)
|
|
|
|
{
|
|
|
|
var value = values[i];
|
|
|
|
var stepValue = Convert.ToInt32(value);
|
2025-09-03 20:14:31 +00:00
|
|
|
var stepName = ProcessStepTextRouter.GetText(value);
|
2024-08-01 19:53:28 +00:00
|
|
|
|
|
|
|
this.labels[i] = stepName;
|
|
|
|
this.stepsData[value] = new ProcessStepValue(stepValue, stepName);
|
|
|
|
|
|
|
|
if (stepValue < this.min)
|
|
|
|
this.min = stepValue;
|
|
|
|
|
|
|
|
if (stepValue > this.max)
|
|
|
|
this.max = stepValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] Labels => this.labels;
|
|
|
|
|
|
|
|
public int Min => this.min;
|
|
|
|
|
|
|
|
public int Max => this.max;
|
|
|
|
|
|
|
|
public ProcessStepValue this[T step] => this.stepsData[step];
|
|
|
|
}
|