Class ItemRange
A helper class for parsing the Range http header on incoming requests and writing the Content-Range http header on outgoing responses.
Inheritance
Inherited Members
Namespace: EPiServer.Shell.Services.Rest
Assembly: EPiServer.Shell.dll
Version: 9.12.2Syntax
public class ItemRange
Constructors
ItemRange()
Initializes a new instance of the ItemRange class.
Declaration
public ItemRange()
Properties
End
Gets or sets the index of the last item requested or returned.
Declaration
public int? End { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Length
Gets the calculated length (number of items) from Start to End.
Declaration
public long? Length { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int64> |
Start
Gets or sets the start index of the requested or returned range of items.
Declaration
public int? Start { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Total
Gets or sets the total number of items. Only used in the response. Null if unknown.
Declaration
public int? Total { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Methods
AddHeaderTo(HttpResponseBase)
Adds the range information to the specified http response.
Declaration
public void AddHeaderTo(HttpResponseBase httpResponse)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpResponseBase | httpResponse | The HTTP response. |
ApplyTo<T>(IEnumerable<T>)
Applies the range (start, end) and returns the items in the range together with the actual range (start, end, total).
Declaration
public virtual RangedItems<T> ApplyTo<T>(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The full item collection to get the range from. |
Returns
Type | Description |
---|---|
RangedItems<T> | A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total). |
Type Parameters
Name | Description |
---|---|
T | The type of items to apply range to. |
ApplyTo<T>(IEnumerable<T>, Nullable<Int32>)
Applies the range (start, end) and returns the items in the range together
with the actual range (start, end, total), using a supplied total count
which means that items
don't have to be enumerated to
get the count.
Declaration
public virtual RangedItems<T> ApplyTo<T>(IEnumerable<T> items, int? totalItemCount)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The full item collection to get the range from. |
System.Nullable<System.Int32> | totalItemCount | The total item count, or null if it should be
reported as unknown. To get the actual total count by enumerating |
Returns
Type | Description |
---|---|
RangedItems<T> | A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total). |
Type Parameters
Name | Description |
---|---|
T | The type of items to apply range to. |
ApplyTo<T>(IQueryable<T>)
Applies the range (start, end) and returns the items in the range together with the actual range (start, end, total). Utilizes the query engine of the IQueryable to avoid fetching all items unless needed.
Declaration
public virtual RangedItems<T> ApplyTo<T>(IQueryable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | items | The full item collection to get the range from. |
Returns
Type | Description |
---|---|
RangedItems<T> | A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total). |
Type Parameters
Name | Description |
---|---|
T | The type of items to apply range to. |
ApplyTo<T>(IQueryable<T>, Nullable<Int32>)
Applies the range (start, end) and returns the items in the range together
with the actual range (start, end, total), using a supplied total count
which means that items
don't have to be enumerated to
get the count.
Declaration
public virtual RangedItems<T> ApplyTo<T>(IQueryable<T> items, int? totalItemCount)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | items | The full item collection to get the range from. |
System.Nullable<System.Int32> | totalItemCount | The total item count, or null if it should be
reported as unknown. To get the actual total count by enumerating |
Returns
Type | Description |
---|---|
RangedItems<T> | A RangedItems<T> instance containing the resulting range of items as well as a new ItemRange instance describing the actual range (including total). |
Type Parameters
Name | Description |
---|---|
T | The type of items to apply range to. |
ReadHeaderFrom(HttpRequestBase)
Creates an ItemRange object from the headers in the specified http request.
Declaration
public static ItemRange ReadHeaderFrom(HttpRequestBase httpRequest)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpRequestBase | httpRequest | The HTTP request. |
Returns
Type | Description |
---|---|
ItemRange | An ItemRange with information about the requested range; or null if the no range information was found in the headers. |