Changed Culture indexer to use case-insensitive language matching. Added GetOrDefault() to return a Culture or the default if not found.
15 lines
569 B
C#
15 lines
569 B
C#
namespace EnvelopeGenerator.Web.Models
|
|
{
|
|
public class Cultures : List<Culture>
|
|
{
|
|
public IEnumerable<string> Languages => this.Select(c => c.Language);
|
|
|
|
public IEnumerable<string> FIClasses => this.Select(c => c.FIClass);
|
|
|
|
public Culture Default => this.First();
|
|
|
|
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));
|
|
}
|
|
} |