/// <summary> /// Initializes a new instance of the <see cref="PagedEnumerableNavigation"/> class using the /// given builder. /// </summary> /// <param name="builder">The builder to use.</param> private PagedEnumerableNavigation(PagedEnumerableNavigationBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (builder.FirstPageNumber > builder.LastPageNumber) { throw new ArgumentOutOfRangeException( paramName: $"{nameof(builder.FirstPageNumber)}", message: $"Parameter: {nameof(builder.FirstPageNumber)} must be less than parameter: ${nameof(builder.LastPageNumber)}"); } if (builder.FirstPageNumber > builder.CurrentPageNumber) { throw new ArgumentOutOfRangeException( paramName: $"{nameof(builder.FirstPageNumber)}", message: $"Parameter: {nameof(builder.FirstPageNumber)} must be less than parameter: ${nameof(builder.CurrentPageNumber)}"); } if (builder.CurrentPageNumber > builder.LastPageNumber) { throw new ArgumentOutOfRangeException( paramName: $"{nameof(builder.CurrentPageNumber)}", message: $"Parameter: {nameof(builder.CurrentPageNumber)} must be less than parameter: ${nameof(builder.LastPageNumber)}"); } this.FirstPageNumber = builder.FirstPageNumber; this.CurrentPageNumber = builder.CurrentPageNumber; this.LastPageNumber = builder.LastPageNumber; }
/// <summary> /// Initializes a new instance of the <see cref="PagedEnumerableNavigation"/> class with default values. /// </summary> /// <remarks> /// Think of this like a default constructor, all properties will have default values and be well formed. /// </remarks> /// <returns>A new instance of the <see cref="PagedEnumerableNavigation"/> class with default values.</returns> public static PagedEnumerableNavigation Default() { // TODO: Unit tests for this. return(Create(PagedEnumerableNavigationBuilder.Create())); }
/// <summary> /// Initializes a new instance of the <see cref="PagedEnumerableNavigation"/> class using the /// given first, last and current page numbers. /// </summary> /// <param name="builder">The builder to use.</param> /// <returns>A new instance of <see cref="PagedEnumerableNavigation"/>.</returns> public static PagedEnumerableNavigation Create(PagedEnumerableNavigationBuilder builder) { return(new PagedEnumerableNavigation(builder)); }