mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-18 05:41:42 +10:00
Reorganise codebase: EffectiveConfig, parsers, tests; move tooltips to Metadata
Infrastructure: - Parsers under Serialization/Parsers: Dnsmasq, DnsmasqConfig, EffectiveConfig - EffectiveConfig: Abstractions, Metadata (keys, views, field builder, tooltips, placeholders, write semantics), Rendering, Editing, Validation/Handlers, Readonly - Helpers/Config: only DnsmasqFileEncoding; DnsmasqOptionTooltips moved to Metadata - Remove empty Infrastructure/Parsers and Helpers/Dnsmasq Tests: - Mirror main project: Serialization/Parsers (Dnsmasq, DnsmasqConfig), Services/Dnsmasq/Config, Services/EffectiveConfig, Models, Helpers (TestDataHelper) - Namespaces updated; usings for TestDataHelper and Metadata where needed Docs: README codebase overview and test layout updated.
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
namespace DnsmasqWebUI.Infrastructure.Services.EffectiveConfig.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// How to serialize an option when writing the managed config file.
|
||||
/// This models write intent, not parse behavior.
|
||||
/// </summary>
|
||||
public enum EffectiveConfigWriteBehavior
|
||||
{
|
||||
Flag,
|
||||
SingleValue,
|
||||
MultiValue,
|
||||
KeyOnlyOrValue,
|
||||
MultiKeyOnlyOrValue,
|
||||
InversePair,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Source of truth for write semantics used by managed-config writing and readonly hints.
|
||||
/// Special options come from <see cref="EffectiveConfigSpecialOptionSemantics"/>; all others
|
||||
/// derive from parser behavior (Flag/Multi/LastWins).
|
||||
/// </summary>
|
||||
public static class EffectiveConfigWriteSemantics
|
||||
{
|
||||
/// <summary>Returns write behavior for an option.</summary>
|
||||
public static EffectiveConfigWriteBehavior GetBehavior(string optionName)
|
||||
{
|
||||
if (EffectiveConfigSpecialOptionSemantics.GetWriteBehavior(optionName) is { } special)
|
||||
return special;
|
||||
return EffectiveConfigParserBehaviorMap.GetBehavior(optionName) switch
|
||||
{
|
||||
EffectiveConfigParserBehavior.Flag => EffectiveConfigWriteBehavior.Flag,
|
||||
EffectiveConfigParserBehavior.Multi => EffectiveConfigWriteBehavior.MultiValue,
|
||||
_ => EffectiveConfigWriteBehavior.SingleValue,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Returns inverse-pair keys (enabled, disabled) for InversePair options; null otherwise.</summary>
|
||||
public static (string KeyA, string KeyB)? GetInversePairKeys(string optionName) =>
|
||||
EffectiveConfigSpecialOptionSemantics.GetInversePairKeys(optionName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user