3 using System.Collections.Generic;
11 private readonly Dictionary<Identifier, string> attributes =
new Dictionary<Identifier, string>();
15 if (elem is
null) {
return; }
16 foreach (var attr
in elem.Attributes())
18 attributes.Add(attr.NameAsIdentifier(), attr.Value);
22 public static void Init(XElement? elem)
29 foreach (var kvp
in attributes)
31 elem.Add(
new XAttribute(kvp.Key.Value, kvp.Value));
37 if (attributes.TryGetValue(key, out
string? val))
39 if (
bool.TryParse(val, out
bool result)) {
return result; }
47 if (attributes.TryGetValue(key, out
string? val))
49 if (Enum.TryParse(val, ignoreCase:
true, out T result)) {
return result; }
57 return attributes.TryGetValue(key, out
string? val)
59 .Select(
static s => s.Trim())
60 .Where(
static s => !s.IsNullOrWhiteSpace())
61 .Select(
static s => s.ToLanguageIdentifier()).ToArray()
67 attributes[key] = val;
LanguageIdentifier[] GetAttributeLanguageIdentifierArray(Identifier key, LanguageIdentifier[] def)
T GetAttributeEnum< T >(Identifier key, T def)
static ServerListFilters Instance
static void Init(XElement? elem)
void SaveTo(XElement elem)
bool GetAttributeBool(Identifier key, bool def)
void SetAttribute(Identifier key, string val)