| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | |
| | | 4 | | namespace MediaBrowser.Model.Querying; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Query result container. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <typeparam name="T">The type of item contained in the query result.</typeparam> |
| | | 10 | | public class QueryResult<T> |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Initializes a new instance of the <see cref="QueryResult{T}" /> class. |
| | | 14 | | /// </summary> |
| | | 15 | | public QueryResult() |
| | | 16 | | { |
| | 3 | 17 | | Items = Array.Empty<T>(); |
| | 3 | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Initializes a new instance of the <see cref="QueryResult{T}" /> class. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <param name="items">The list of items.</param> |
| | | 24 | | public QueryResult(IReadOnlyList<T> items) |
| | | 25 | | { |
| | 3 | 26 | | Items = items; |
| | 3 | 27 | | TotalRecordCount = items.Count; |
| | 3 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Initializes a new instance of the <see cref="QueryResult{T}" /> class. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <param name="startIndex">The start index that was used to build the item list.</param> |
| | | 34 | | /// <param name="totalRecordCount">The total count of items.</param> |
| | | 35 | | /// <param name="items">The list of items.</param> |
| | | 36 | | public QueryResult(int? startIndex, int? totalRecordCount, IReadOnlyList<T> items) |
| | | 37 | | { |
| | 134 | 38 | | StartIndex = startIndex ?? 0; |
| | 134 | 39 | | TotalRecordCount = totalRecordCount ?? items.Count; |
| | 134 | 40 | | Items = items; |
| | 134 | 41 | | } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Gets or sets the items. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <value>The items.</value> |
| | | 47 | | public IReadOnlyList<T> Items { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets or sets the total number of records available. |
| | | 51 | | /// </summary> |
| | | 52 | | /// <value>The total record count.</value> |
| | | 53 | | public int TotalRecordCount { get; set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets or sets the index of the first record in Items. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <value>First record index.</value> |
| | | 59 | | public int StartIndex { get; set; } |
| | | 60 | | } |