public LanguagesConfig Set(LanguageConfig config) { Guard.NotNull(config, nameof(config)); return(new LanguagesConfig(languages.SetItem(config.Language, config), Master?.Language == config.Language ? config : Master)); }
private LanguagesConfig(ImmutableDictionary <Language, LanguageConfig> languages, LanguageConfig master, bool checkMaster = true) { if (checkMaster) { this.master = master ?? throw new InvalidOperationException("Config has no master language."); } foreach (var languageConfig in languages.Values) { foreach (var fallback in languageConfig.LanguageFallbacks) { if (!languages.ContainsKey(fallback)) { var message = $"Config for language '{languageConfig.Language.Iso2Code}' contains unsupported fallback language '{fallback.Iso2Code}'"; throw new InvalidOperationException(message); } } } this.languages = languages; }
public bool TryGetConfig(Language language, out LanguageConfig config) { return(languages.TryGetValue(language, out config)); }
public void Set(LanguageConfig config) { Guard.NotNull(config, nameof(config)); state = new State(state.Languages.SetItem(config.Language, config), state.Master?.Language == config.Language ? config : state.Master); }
public bool TryGetConfig(Language language, [MaybeNullWhen(false)] out LanguageConfig config) { return(languages.TryGetValue(language, out config !)); }
private LanguagesConfig Create(ArrayDictionary <Language, LanguageConfig> newLanguages, LanguageConfig newMaster) { if (newLanguages.EqualsDictionary(languages, EqualityComparer <Language> .Default, DeepComparer <LanguageConfig> .Instance) && newMaster.Language.Equals(master.Language)) { return(this); } return(new LanguagesConfig(newLanguages, newMaster)); }