mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-04 04:18:13 +10:00
- Add EffectiveConfigOptionKindMap (Single/Multi kind + LastWins/Flag/Multi parser behavior) and drive field builder + ConfigSetCache from it. - Single AddDescriptor() in list extensions that dispatches via kind map to AddSingleDescriptor/AddMultiDescriptor. - ConfigSetCache: ParseOptionValue/ParseOptionWithSource dispatch by option name; BuildEffectiveConfig and BuildEffectiveConfigSources use them with casts; special cases (NoHosts, AddnHosts, server/local, DhcpLeaseFilePath) remain explicit. - Add IntegerValueDisplay, LogQueriesDisplay, LocalServiceDisplay; register integers with bounds/units in EffectiveConfigRenderFragmentRegistry. - Add EffectiveConfigDescriptorFactory, EffectiveIntegerConfigFieldDescriptor, IEffectiveConfigFieldDescriptor for integer descriptor metadata.
23 lines
966 B
C#
23 lines
966 B
C#
using DnsmasqWebUI.Models.Dnsmasq;
|
|
using DnsmasqWebUI.Models.Dnsmasq.EffectiveConfig.Abstractions;
|
|
|
|
namespace DnsmasqWebUI.Models.Dnsmasq.EffectiveConfig;
|
|
|
|
/// <summary>
|
|
/// Glue for rendering one effective-config field: metadata (section, option name) plus delegates that resolve value, source, and items from Status at render time.
|
|
/// </summary>
|
|
public record EffectiveConfigFieldDescriptor(
|
|
string SectionId,
|
|
string OptionName,
|
|
bool IsMultiValue,
|
|
DnsmasqServiceStatus? Status,
|
|
Func<DnsmasqServiceStatus?, object?>? ResolveValue,
|
|
Func<DnsmasqServiceStatus?, ConfigValueSource?>? ResolveSource,
|
|
Func<DnsmasqServiceStatus?, IReadOnlyList<ValueWithSource>?>? ResolveItems
|
|
) : IEffectiveConfigFieldDescriptor
|
|
{
|
|
public object? GetValue() => ResolveValue?.Invoke(Status);
|
|
public ConfigValueSource? GetSource() => ResolveSource?.Invoke(Status);
|
|
public IReadOnlyList<ValueWithSource>? GetItems() => ResolveItems?.Invoke(Status);
|
|
}
|