Esempio n. 1
0
        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));
                }
            }
        }
Esempio n. 2
0
        private IEnumerable<FieldConverter> GenerateConverters(QueryContext context, bool checkType)
        {
            if (!context.IsFrontendClient)
            {
                yield return FieldConverters.ExcludeHidden();
            }

            if (checkType)
            {
                yield return FieldConverters.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);
                }
            }
        }
Esempio n. 3
0
        public void Should_return_null_values_if_field_hidden()
        {
            var source = new ContentFieldData();

            var result = FieldConverters.ExcludeHidden()(source, stringLanguageField.Hide());

            Assert.Null(result);
        }
Esempio n. 4
0
        public void Should_return_same_values_if_field_not_hidden()
        {
            var source = new ContentFieldData();

            var result = FieldConverters.ExcludeHidden()(source, stringLanguageField);

            Assert.Same(source, result);
        }
        public void Should_return_null_if_field_hidden()
        {
            var field = Fields.String(1, "string", Partitioning.Language);

            var source = new ContentFieldData();

            var result = FieldConverters.ExcludeHidden(source, field.Hide());

            Assert.Null(result);
        }
        public void Should_return_field_data_if_field_not_hidden()
        {
            var field = Fields.String(1, "string", Partitioning.Language);

            var source = new ContentFieldData();

            var result = FieldConverters.ExcludeHidden(source, field);

            Assert.Equal(source, result);
        }
Esempio n. 7
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));
                }
            }
        }