/// <summary>
        /// Returns taxonomy groups.
        /// </summary>
        /// <param name="parameters">A collection of query parameters, for example, for paging.</param>
        /// <returns>The <see cref="DeliveryTaxonomyListingResponse"/> instance that represents the taxonomy groups. If no query parameters are specified, all taxonomy groups are returned.</returns>
        public async Task <DeliveryTaxonomyListingResponse> GetTaxonomiesAsync(IEnumerable <IQueryParameter> parameters)
        {
            var identifierTokens = new List <string> {
                KenticoCloudCacheHelper.TAXONOMY_GROUP_LISTING_IDENTIFIER
            };

            identifierTokens.AddNonNullRange(KenticoCloudCacheHelper.GetIdentifiersFromParameters(parameters));

            return(await CacheManager.GetOrCreateAsync(
                       identifierTokens,
                       () => DeliveryClient.GetTaxonomiesAsync(parameters),
                       response => response.Taxonomies.Count <= 0,
                       GetTaxonomyListingDependencies,
                       ProjectOptions.CreateCacheEntriesInBackground));
        }
        public async Task <DeliveryItemListingResponse <T> > GetItemsAsync <T>(IEnumerable <IQueryParameter> parameters)
        {
            var identifierTokens = new List <string> {
                KenticoCloudCacheHelper.CONTENT_ITEM_LISTING_TYPED_IDENTIFIER
            };

            identifierTokens.AddNonNullRange(KenticoCloudCacheHelper.GetIdentifiersFromParameters(parameters));

            return(await CacheManager.GetOrCreateAsync(
                       identifierTokens,
                       () => DeliveryClient.GetItemsAsync <T>(parameters),
                       response => response.Items.Count <= 0,
                       GetContentItemListingDependencies,
                       ProjectOptions.CreateCacheEntriesInBackground));
        }
        /// <summary>
        /// Gets one strongly typed content item by its codename.
        /// </summary>
        /// <typeparam name="T">Type of the code-first model. (Or <see cref="object"/> if the return type is not yet known.)</typeparam>
        /// <param name="codename">The codename of a content item.</param>
        /// <param name="parameters">A collection of query parameters, for example for projection or depth of linked items.</param>
        /// <returns>The <see cref="DeliveryItemResponse{T}"/> instance that contains the content item with the specified codename.</returns>
        public async Task <DeliveryItemResponse <T> > GetItemAsync <T>(string codename, IEnumerable <IQueryParameter> parameters = null)
        {
            var identifierTokens = new List <string> {
                KenticoCloudCacheHelper.CONTENT_ITEM_SINGLE_TYPED_IDENTIFIER, codename
            };

            identifierTokens.AddNonNullRange(KenticoCloudCacheHelper.GetIdentifiersFromParameters(parameters));

            return(await CacheManager.GetOrCreateAsync(
                       identifierTokens,
                       () => DeliveryClient.GetItemAsync <T>(codename, parameters),
                       response => response == null,
                       GetContentItemSingleDependencies,
                       ProjectOptions.CreateCacheEntriesInBackground));
        }
Example #4
0
        /// <summary>
        /// Returns taxonomy groups.
        /// </summary>
        /// <param name="parameters">A collection of query parameters, for example, for paging.</param>
        /// <returns>The <see cref="DeliveryTaxonomyListingResponse"/> instance that represents the taxonomy groups. If no query parameters are specified, all taxonomy groups are returned.</returns>
        public async Task <DeliveryTaxonomyListingResponse> GetTaxonomiesAsync(IEnumerable <IQueryParameter> parameters)
        {
            var cacheTokens = new List <string> {
                KenticoCloudCacheHelper.TAXONOMY_GROUP_LISTING_IDENTIFIER
            };

            cacheTokens.AddNonNullRange(KenticoCloudCacheHelper.GetIdentifiersFromParameters(parameters));

            return(await _cacheManager.GetOrCreateAsync(
                       cacheTokens,
                       () => _deliveryClient.GetTaxonomiesAsync(parameters),
                       _previewDeliveryClient == null?(Func <Task <DeliveryTaxonomyListingResponse> >) null : () => _previewDeliveryClient.GetTaxonomiesAsync(parameters),
                       response => response.Taxonomies.Count <= 0,
                       _dependencyResolver.GetTaxonomyListingDependencies));
        }
Example #5
0
        public async Task <DeliveryItemListingResponse <T> > GetItemsAsync <T>(IEnumerable <IQueryParameter> parameters)
        {
            var cacheTokens = new List <string> {
                KenticoCloudCacheHelper.CONTENT_ITEM_LISTING_TYPED_IDENTIFIER
            };

            cacheTokens.AddNonNullRange(KenticoCloudCacheHelper.GetIdentifiersFromParameters(parameters));

            return(await _cacheManager.GetOrCreateAsync(
                       cacheTokens,
                       () => _deliveryClient.GetItemsAsync <T>(parameters),
                       _previewDeliveryClient == null?(Func <Task <DeliveryItemListingResponse <T> > >) null : () => _previewDeliveryClient.GetItemsAsync <T>(parameters),
                       response => response.Items.Count <= 0,
                       _dependencyResolver.GetItemListingResponseDependencies));
        }
Example #6
0
        /// <summary>
        /// Returns a content item.
        /// </summary>
        /// <param name="codename">The codename of a content item.</param>
        /// <param name="parameters">A collection of query parameters, for example for projection or depth of modular content.</param>
        /// <returns>The <see cref="DeliveryItemResponse"/> instance that contains the content item with the specified codename.</returns>
        public async Task <DeliveryItemResponse> GetItemAsync(string codename, IEnumerable <IQueryParameter> parameters)
        {
            var cacheTokens = new List <string> {
                KenticoCloudCacheHelper.CONTENT_ITEM_SINGLE_IDENTIFIER, codename
            };

            cacheTokens.AddNonNullRange(KenticoCloudCacheHelper.GetIdentifiersFromParameters(parameters));

            return(await _cacheManager.GetOrCreateAsync(
                       cacheTokens,
                       () => _deliveryClient.GetItemAsync(codename, parameters),
                       _previewDeliveryClient == null?(Func <Task <DeliveryItemResponse> >) null : () => _previewDeliveryClient.GetItemAsync(codename, parameters),
                       response => response == null,
                       _dependencyResolver.GetItemResponseDependencies));
        }