/// <summary> /// Send a <see cref="HttpMethod.Get"/> request as an asynchronous operation converting the expected collection response to a <see cref="EntityCollectionResult{TColl, TEntity}"/>. /// </summary> /// <typeparam name="TResult">The result <see cref="Type"/>.</typeparam> /// <typeparam name="TColl">The collection <see cref="Type"/>.</typeparam> /// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam> /// <param name="urlSuffix">The url suffix for the operation.</param> /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param> /// <param name="args">The operation arguments to be substituted within the <paramref name="urlSuffix"/>.</param> /// <param name="memberName">The method or property name of the caller to the method.</param> /// <param name="filePath">The full path of the source file that contains the caller.</param> /// <param name="lineNumber">The line number in the source file at which the method is called.</param> /// <returns>The <see cref="WebApiAgentResult{TResult}"/>.</returns> public async Task <WebApiAgentResult <TResult> > GetCollectionResultAsync <TResult, TColl, TEntity>(string urlSuffix, WebApiRequestOptions?requestOptions = null, WebApiArg[]?args = null, [CallerMemberName] string?memberName = null, [CallerFilePath] string?filePath = null, [CallerLineNumber] int lineNumber = 0) where TResult : EntityCollectionResult <TColl, TEntity>, new() where TColl : EntityBaseCollection <TEntity>, new() where TEntity : EntityBase { var result = await GetAsync <TColl>(urlSuffix, requestOptions, args, memberName, filePath, lineNumber).ConfigureAwait(false); if (!result.Response.IsSuccessStatusCode) { return(new WebApiAgentResult <TResult>(result)); } var collResult = new TResult() { Result = result.Value }; var skip = GetHeaderValueLong(result, WebApiConsts.PagingSkipHeaderName); var page = skip.HasValue ? null : GetHeaderValueLong(result, WebApiConsts.PagingPageNumberHeaderName); if (skip.HasValue) { collResult.Paging = new PagingResult(PagingResult.CreateSkipAndTake(skip.Value, GetHeaderValueLong(result, WebApiConsts.PagingTakeHeaderName))); } else if (page.HasValue && result.Response.Headers.Contains(WebApiConsts.PagingPageNumberHeaderName)) { collResult.Paging = new PagingResult(PagingResult.CreatePageAndSize(page.Value, GetHeaderValueLong(result, WebApiConsts.PagingPageSizeHeaderName))); } if (collResult.Paging != null) { collResult.Paging.TotalCount = GetHeaderValueLong(result, WebApiConsts.PagingTotalCountHeaderName); } return(new WebApiAgentResult <TResult>(result, collResult)); }