Make Culture lookup case-insensitive; add GetOrDefault()

Changed Culture indexer to use case-insensitive language matching.
Added GetOrDefault() to return a Culture or the default if not found.
This commit is contained in:
2026-02-11 13:50:02 +01:00
parent 9f59a17f63
commit 91eb5d1e64

View File

@@ -8,6 +8,8 @@
public Culture Default => this.First(); public Culture Default => this.First();
public Culture? this[string? language] => language is null ? null : this.Where(c => c.Language == language).FirstOrDefault(); public Culture GetOrDefault(string? language) => this[language] ?? Default;
public Culture? this[string? language] => language is null ? null : this.FirstOrDefault(c => string.Equals(c.Language, language, StringComparison.OrdinalIgnoreCase));
} }
} }