コード例 #1
0
ファイル: ContentQueryService.cs プロジェクト: neoayi/squidex
        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));
                }
            }
        }
コード例 #2
0
        public void Should_return_null_if_field_has_wrong_type()
        {
            var source = JsonValue.Create("invalid");

            var result = ValueConverters.ExcludeChangedTypes(source, numberField);

            Assert.Null(result);
        }
コード例 #3
0
        public void Should_return_unset_if_field_has_wrong_type()
        {
            var source = "invalid";

            var result = ValueConverters.ExcludeChangedTypes()(source, numberField);

            Assert.Same(Value.Unset, result);
        }
コード例 #4
0
ファイル: ConvertData.cs プロジェクト: seamys/squidex
        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);
        }
コード例 #5
0
ファイル: ConvertData.cs プロジェクト: jrlost/squidex
        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));
                }
            }
        }
コード例 #6
0
        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));
                }
            }
        }
コード例 #7
0
        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));
        }