Forge
csharpdeeb25a2
1#nullable enable
2
3namespace CascadeIDE.Models;
4
5/// <summary>
6/// Fluent-сборка списка <see cref="AnnunciatorLampItem"/> для полосы ламп (сахар над конструктором record).
7/// </summary>
8/// <example>
9/// <code>
10/// var items = AnnunciatorLampStripBuilder.Create()
11/// .AddLamp(EnvironmentReadinessCellIds.MarkdownLsp, "MD", AnnunciatorLampLevel.Ok, "Markdown LSP", "")
12/// .AddLamp(EnvironmentReadinessCellIds.CSharpLsp, "C#", AnnunciatorLampLevel.Caution, "C# LSP", "Не поднят")
13/// .Build();
14/// </code>
15/// </example>
16public sealed class AnnunciatorLampStripBuilder
17{
18 private readonly List<AnnunciatorLampItem> _items = [];
19
20 public static AnnunciatorLampStripBuilder Create() => new();
21
22 /// <param name="id">Стабильный id (<see cref="EnvironmentReadinessCellIds"/> или свой для прототипа).</param>
23 /// <param name="lampShortLabel">Подпись на лампе.</param>
24 /// <param name="title">Заголовок тултипа; по умолчанию = <paramref name="lampShortLabel"/>.</param>
25 /// <param name="detail">Текст тултипа; по умолчанию пусто.</param>
26 public AnnunciatorLampStripBuilder AddLamp(
27 string id,
28 string lampShortLabel,
29 AnnunciatorLampLevel level,
30 string? title = null,
31 string? detail = null)
32 {
33 ArgumentException.ThrowIfNullOrEmpty(id);
34 ArgumentException.ThrowIfNullOrEmpty(lampShortLabel);
35
36 _items.Add(new AnnunciatorLampItem(
37 id,
38 title ?? lampShortLabel,
39 detail ?? "",
40 level,
41 lampShortLabel));
42 return this;
43 }
44
45 public IReadOnlyList<AnnunciatorLampItem> Build() => _items;
46}
47
View only · write via MCP/CIDE