Table of Contents

Struct PageRange

Namespace
DocWright.Core.Primitives
Assembly
DocWright.Core.dll

An inclusive, 1-based selection of page numbers. The default value is All.

public readonly struct PageRange : IEquatable<PageRange>
Implements
Inherited Members

Remarks

A selection is one contiguous span in the common case and a sorted set of disjoint spans when a caller asks for something like 1-3,7,12-. It stays a single type rather than growing a companion "page set" beside it, because every consumer — the PDF renderer, the imaging renderer, the facade and the PDF rasterizer — already takes a PageRange, and two page-selection vocabularies would mean two things to keep in agreement forever.

FirstPage and LastPage therefore describe the bounding span of the selection, not its membership; Contains(int) is the only correct membership test and always has been.

Constructors

PageRange(int, int)

Initializes a range from the first to the last page, inclusive.

Properties

All

Gets the range covering every page.

FirstPage

Gets the 1-based first page of the selection's bounding span.

IsAll

Gets a value indicating whether this range covers every page.

IsUnbounded

Gets a value indicating whether the selection runs to the end of the document — an open-ended tail such as 12-, whose last page is not known until the document is.

LastPage

Gets the 1-based last page (inclusive) of the selection's bounding span.

SegmentCount

Gets the number of disjoint contiguous spans in the selection. One for a plain range.

Methods

Contains(int)

Determines whether the selection contains the given page.

Equals(PageRange)
Equals(object?)
GetHashCode()
GetSegment(int)

Gets one of the selection's disjoint contiguous spans, in ascending page order.

Parse(string)

Parses a page selection such as 1-3,7,12-, 4 or all.

Single(int)

Creates a range containing a single page.

ToString()

Returns "all" for the full range, otherwise the selection in Parse(string)'s own grammar with invariant formatting — so the two round-trip.

TryParse(string?, out PageRange)

Attempts to parse a page selection such as 1-3,7,12-, 4 or all.

Union(params PageRange[])

Creates the union of several ranges, sorted and merged.

Operators

operator ==(PageRange, PageRange)

Determines whether two ranges are equal.

operator !=(PageRange, PageRange)

Determines whether two ranges are not equal.