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:
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user