namespace DnsmasqWebUI.Infrastructure.Services.EffectiveConfig.Metadata; /// /// How to serialize an option when writing the managed config file. /// This models write intent, not parse behavior. /// public enum EffectiveConfigWriteBehavior { Flag, SingleValue, MultiValue, KeyOnlyOrValue, MultiKeyOnlyOrValue, InversePair, } /// /// Source of truth for write semantics used by managed-config writing and readonly hints. /// Special options come from ; all others /// derive from parser behavior (Flag/Multi/LastWins). /// public static class EffectiveConfigWriteSemantics { /// Returns write behavior for an option. 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, }; } /// Returns inverse-pair keys (enabled, disabled) for InversePair options; null otherwise. public static (string KeyA, string KeyB)? GetInversePairKeys(string optionName) => EffectiveConfigSpecialOptionSemantics.GetInversePairKeys(optionName); }