private IEnumerable <FieldConverter> GenerateConverters(QueryContext context) { if (!context.IsFrontendClient) { yield return(FieldConverters.ExcludeHidden()); yield return(FieldConverters.ForNestedName2Name(ValueConverters.ExcludeHidden())); } yield return(FieldConverters.ExcludeChangedTypes()); yield return(FieldConverters.ForNestedName2Name(ValueConverters.ExcludeChangedTypes())); yield return(FieldConverters.ResolveInvariant(context.App.LanguagesConfig)); yield return(FieldConverters.ResolveLanguages(context.App.LanguagesConfig)); if (!context.IsFrontendClient) { yield return(FieldConverters.ResolveFallbackLanguages(context.App.LanguagesConfig)); if (context.Languages?.Any() == true) { yield return(FieldConverters.FilterLanguages(context.App.LanguagesConfig, context.Languages)); } if (context.AssetUrlsToResolve?.Any() == true) { yield return(FieldConverters.ResolveAssetUrls(context.AssetUrlsToResolve, assetUrlGenerator)); } } }
public void Should_return_null_if_field_has_wrong_type() { var source = JsonValue.Create("invalid"); var result = ValueConverters.ExcludeChangedTypes(source, numberField); Assert.Null(result); }
public void Should_return_unset_if_field_has_wrong_type() { var source = "invalid"; var result = ValueConverters.ExcludeChangedTypes()(source, numberField); Assert.Same(Value.Unset, result); }
public ConvertData(IUrlGenerator urlGenerator, IJsonSerializer jsonSerializer, IAssetRepository assetRepository, IContentRepository contentRepository) { this.urlGenerator = urlGenerator; this.assetRepository = assetRepository; this.contentRepository = contentRepository; excludedChangedField = FieldConverters.ExcludeChangedTypes(jsonSerializer); excludedChangedValue = FieldConverters.ForValues(ValueConverters.ExcludeChangedTypes(jsonSerializer)); excludedHiddenField = FieldConverters.ExcludeHidden; excludedHiddenValue = FieldConverters.ForValues(ValueConverters.ExcludeHidden); }
private IEnumerable <FieldConverter> GenerateConverters(Context context, ResolvedComponents components, ValueConverter?cleanReferences) { if (!context.IsFrontendClient) { yield return(excludedHiddenField); yield return(FieldConverters.ForValues(components, ValueConverters.ExcludeHidden)); } yield return(excludedChangedField); yield return(FieldConverters.ForValues(components, ValueConverters.ExcludeChangedTypes(jsonSerializer))); if (cleanReferences != null) { yield return(FieldConverters.ForValues(components, cleanReferences)); } yield return(FieldConverters.ResolveInvariant(context.App.Languages)); yield return(FieldConverters.ResolveLanguages(context.App.Languages)); if (!context.IsFrontendClient) { if (context.ShouldResolveLanguages()) { yield return(FieldConverters.ResolveFallbackLanguages(context.App.Languages)); } var languages = context.Languages(); if (languages.Any()) { yield return(FieldConverters.FilterLanguages(context.App.Languages, languages)); } var assetUrls = context.AssetUrls().ToList(); if (assetUrls.Count > 0) { var appId = context.App.NamedId(); var resolveAssetUrls = ValueConverters.ResolveAssetUrls(appId, assetUrls, urlGenerator); yield return(FieldConverters.ForValues(components, resolveAssetUrls)); } } }
private IEnumerable <FieldConverter> GenerateConverters(Context context, ValueConverter?cleanReferences) { if (!context.IsFrontendClient) { yield return(FieldConverters.ExcludeHidden()); yield return(FieldConverters.ForNestedName2Name(ValueConverters.ExcludeHidden())); } yield return(FieldConverters.ExcludeChangedTypes()); yield return(FieldConverters.ForNestedName2Name(ValueConverters.ExcludeChangedTypes())); if (cleanReferences != null) { yield return(FieldConverters.ForValues(cleanReferences)); yield return(FieldConverters.ForNestedName2Name(cleanReferences)); } yield return(FieldConverters.ResolveInvariant(context.App.LanguagesConfig)); yield return(FieldConverters.ResolveLanguages(context.App.LanguagesConfig)); if (!context.IsFrontendClient) { if (context.ShouldResolveLanguages()) { yield return(FieldConverters.ResolveFallbackLanguages(context.App.LanguagesConfig)); } var languages = context.Languages(); if (languages.Any()) { yield return(FieldConverters.FilterLanguages(context.App.LanguagesConfig, languages)); } var assetUrls = context.AssetUrls(); if (assetUrls.Any()) { yield return(FieldConverters.ResolveAssetUrls(assetUrls.ToList(), assetUrlGenerator)); } } }
public ConvertData(IUrlGenerator urlGenerator, IJsonSerializer jsonSerializer, IAssetRepository assetRepository, IContentRepository contentRepository) { Guard.NotNull(urlGenerator, nameof(urlGenerator)); Guard.NotNull(jsonSerializer, nameof(jsonSerializer)); Guard.NotNull(assetRepository, nameof(assetRepository)); Guard.NotNull(contentRepository, nameof(contentRepository)); this.urlGenerator = urlGenerator; this.assetRepository = assetRepository; this.contentRepository = contentRepository; excludedChangedField = FieldConverters.ExcludeChangedTypes(jsonSerializer); excludedChangedValue = FieldConverters.ForValues(ValueConverters.ForNested(ValueConverters.ExcludeChangedTypes(jsonSerializer))); excludedHiddenField = FieldConverters.ExcludeHidden; excludedHiddenValue = FieldConverters.ForValues(ValueConverters.ForNested(ValueConverters.ExcludeHidden)); }