protected void On(AppLanguageUpdated @event) { LanguagesConfig = LanguagesConfig.Set(@event.Language, @event.IsOptional, @event.Fallback); if (@event.IsMaster) { LanguagesConfig = LanguagesConfig.MakeMaster(@event.Language); } }
public void CanRemoveLanguage_should_not_throw_exception_if_language_is_valid() { var command = new RemoveLanguage { Language = Language.EN }; var languages_1 = languages_0.Set(new LanguageConfig(Language.EN)); GuardAppLanguages.CanRemove(languages_1, command); }
public static void Apply(this LanguagesConfig languagesConfig, AppLanguageUpdated @event) { var fallback = @event.Fallback; if (fallback != null && fallback.Count > 0) { var existingLangauges = languagesConfig.OfType <LanguageConfig>().Select(x => x.Language); fallback = fallback.Intersect(existingLangauges).ToList(); } languagesConfig.Set(new LanguageConfig(@event.Language, @event.IsOptional, fallback)); if (@event.IsMaster) { languagesConfig.MakeMaster(@event.Language); } }
public void Should_return_language_from_fallback_if_found() { var config_1 = languagesConfig.Set(new LanguageConfig(Language.IT)); var config_2 = config_1.Set(new LanguageConfig(Language.ES, false, Language.IT)); var source = new ContentFieldData() .AddValue("en", "EN") .AddValue("it", "IT"); var expected = new ContentFieldData() .AddValue("en", "EN") .AddValue("de", "EN") .AddValue("it", "IT") .AddValue("es", "IT"); var result = FieldConverters.ResolveFallbackLanguages(config_2)(source, stringLanguageField); Assert.Equal(expected, result); }
public void Should_not_throw_exception_if_language_to_add_already_exists() { config_0.Set(Language.EN); }
public static LanguagesConfig Apply(this LanguagesConfig languagesConfig, AppLanguageAdded @event) { return(languagesConfig.Set(new LanguageConfig(@event.Language))); }
protected void On(AppLanguageAdded @event) { LanguagesConfig = LanguagesConfig.Set(@event.Language); }
public void ApplyEvent(IEvent @event) { switch (@event) { case AppCreated e: { Roles = Roles.CreateDefaults(e.Name); SimpleMapper.Map(e, this); break; } case AppUpdated e: { SimpleMapper.Map(e, this); break; } case AppImageUploaded e: { Image = e.Image; break; } case AppImageRemoved _: { Image = null; break; } case AppPlanChanged e: { Plan = AppPlan.Build(e.Actor, e.PlanId); break; } case AppPlanReset _: { Plan = null; break; } case AppContributorAssigned e: { Contributors = Contributors.Assign(e.ContributorId, e.Role); break; } case AppContributorRemoved e: { Contributors = Contributors.Remove(e.ContributorId); break; } case AppClientAttached e: { Clients = Clients.Add(e.Id, e.Secret); break; } case AppClientUpdated e: { Clients = Clients.Update(e.Id, e.Role); break; } case AppClientRenamed e: { Clients = Clients.Rename(e.Id, e.Name); break; } case AppClientRevoked e: { Clients = Clients.Revoke(e.Id); break; } case AppWorkflowAdded e: { Workflows = Workflows.Add(e.WorkflowId, e.Name); break; } case AppWorkflowUpdated e: { Workflows = Workflows.Update(e.WorkflowId, e.Workflow); break; } case AppWorkflowDeleted e: { Workflows = Workflows.Remove(e.WorkflowId); break; } case AppPatternAdded e: { Patterns = Patterns.Add(e.PatternId, e.Name, e.Pattern, e.Message); break; } case AppPatternDeleted e: { Patterns = Patterns.Remove(e.PatternId); break; } case AppPatternUpdated e: { Patterns = Patterns.Update(e.PatternId, e.Name, e.Pattern, e.Message); break; } case AppRoleAdded e: { Roles = Roles.Add(e.Name); break; } case AppRoleDeleted e: { Roles = Roles.Remove(e.Name); break; } case AppRoleUpdated e: { Roles = Roles.Update(e.Name, e.Permissions.Prefix(Name)); break; } case AppLanguageAdded e: { LanguagesConfig = LanguagesConfig.Set(e.Language); break; } case AppLanguageRemoved e: { LanguagesConfig = LanguagesConfig.Remove(e.Language); break; } case AppLanguageUpdated e: { LanguagesConfig = LanguagesConfig.Set(e.Language, e.IsOptional, e.Fallback); if (e.IsMaster) { LanguagesConfig = LanguagesConfig.MakeMaster(e.Language); } break; } case AppArchived _: { Plan = null; IsArchived = true; break; } } }
public static void Apply(this LanguagesConfig languagesConfig, AppLanguageAdded @event) { languagesConfig.Set(new LanguageConfig(@event.Language)); }