private LoaderOptions CreateDefaultListOption()
        {
            LoaderOptions loaderOptions = new LoaderOptions();

            loaderOptions.Add <LanguageLoaderOption>(LanguageLoaderOption.Fallback(_languageAccessor.Language));
            return(loaderOptions);
        }
Esempio n. 2
0
        public TTarget GetContent <TTarget>(DocumentIndexModel indexItem, bool filterOnCulture = true) where TTarget : ContentData
        {
            if (indexItem == null || string.IsNullOrEmpty(indexItem.Id))
            {
                return(default(TTarget));
            }
            Guid result;

            if (Guid.TryParse(((IEnumerable <string>)indexItem.Id.Split('|')).FirstOrDefault <string>(), out result))
            {
                LoaderOptions loaderOptions;
                if (filterOnCulture)
                {
                    loaderOptions = this.GetLoaderOptions(indexItem.Language);
                }
                else
                {
                    loaderOptions = new LoaderOptions();
                    loaderOptions.Add <LanguageLoaderOption>(LanguageLoaderOption.Fallback((CultureInfo)null));
                }
                LoaderOptions settings = loaderOptions;
                TTarget       content  = null;
                this._contentRepository.TryGet <TTarget>(result, settings, out content);
                return(content);
            }
            return(default(TTarget));
        }
Esempio n. 3
0
 protected virtual LoaderOptions CreateDefaultListOptions()
 {
     return(new LoaderOptions
     {
         LanguageLoaderOption.Fallback(LanguageResolver.GetPreferredCulture())
     });
 }
Esempio n. 4
0
        /// <summary>
        /// Gets a list of populated syndication items created from the dependent content references on the gived SyndicationFeedPage.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <SyndicationItem> GetSyndicationItems()
        {
            var contentReferences = FeedContentResolver.GetContentReferences(FeedContext);
            var contentItems      = ContentLoader.GetItems(contentReferences, new LoaderOptions {
                LanguageLoaderOption.Fallback()
            });
            var filteredItems    = FeedFilterer.FilterSyndicationContent(contentItems, FeedContext);
            var syndicationItems = filteredItems.Select(CreateSyndicationItem).ToList();

            return(syndicationItems.OrderByDescending(c => c.LastUpdatedTime).Take(FeedContext.FeedPageType.MaximumItems));
        }
Esempio n. 5
0
        public static LoaderOptions CreateLoaderOptionsFromAgruments <TSource>(this ResolveFieldContext <TSource> context)
        {
            if (!context.HasArgument(Constants.Arguments.ARGUMENT_ALLOWFALLBACK_LANG))
            {
                throw new ArgumentException($"ResolveFieldContext does not contain any argument \"{Constants.Arguments.ARGUMENT_ALLOWFALLBACK_LANG}\"");
            }

            var allowFallbackLang = context.GetArgument <bool>(Constants.Arguments.ARGUMENT_ALLOWFALLBACK_LANG);
            var locale            = context.GetLocaleFromArgument();

            return(new LoaderOptions
            {
                allowFallbackLang
                    ? LanguageLoaderOption.Fallback(locale)
                    : LanguageLoaderOption.Specific(locale)
            });
        }