Пример #1
0
            private void ApplyOptionsInEntry(MutablePaginationEntry entry, IJsonApiOptions options)
            {
                if (!entry.HasSetPageSize)
                {
                    entry.PageSize = options.DefaultPageSize;
                }

                entry.PageNumber ??= PageNumber.ValueOne;
            }
Пример #2
0
        /// <inheritdoc />
        public virtual IReadOnlyCollection <ExpressionInScope> GetConstraints()
        {
            var context = new PaginationContext();

            foreach (PaginationElementQueryStringValueExpression element in _pageSizeConstraint?.Elements ??
                     Array.Empty <PaginationElementQueryStringValueExpression>())
            {
                MutablePaginationEntry entry = context.ResolveEntryInScope(element.Scope);
                entry.PageSize       = element.Value == 0 ? null : new PageSize(element.Value);
                entry.HasSetPageSize = true;
            }

            foreach (PaginationElementQueryStringValueExpression element in _pageNumberConstraint?.Elements ??
                     Array.Empty <PaginationElementQueryStringValueExpression>())
            {
                MutablePaginationEntry entry = context.ResolveEntryInScope(element.Scope);
                entry.PageNumber = new PageNumber(element.Value);
            }

            context.ApplyOptions(_options);

            return(context.GetExpressionsInScope());
        }