| | 1 | | using System.Text.Json.Serialization; |
| | 2 | |
|
| | 3 | | namespace Common.Core.Classes; |
| | 4 | |
|
| | 5 | | /// <summary>Class that contains the properties of a data result set.</summary> |
| | 6 | | /// <typeparam name="T">Generic class or interface.</typeparam> |
| | 7 | | public class ResultsSet<T> where T : class |
| | 8 | | { |
| | 9 | | /// <summary>Gets or sets the total count of the results.</summary> |
| | 10 | | [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] |
| 1 | 11 | | public int? Total { get; set; } |
| | 12 | |
|
| | 13 | | /// <summary>Gets or sets the previous start position.</summary> |
| | 14 | | [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] |
| 1 | 15 | | public string? Previous { get; set; } |
| | 16 | |
|
| | 17 | | /// <summary>Gets or sets the next start position.</summary> |
| | 18 | | [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] |
| 1 | 19 | | public string? Next { get; set; } |
| | 20 | |
|
| | 21 | | /// <summary>Gets or sets the results collection.</summary> |
| 7 | 22 | | public ICollection<T> Results { get; set; } = new List<T>(); |
| | 23 | |
|
| | 24 | | /// <summary>Gets the maximum numbers of results to return.</summary> |
| | 25 | | [JsonIgnore] |
| 6 | 26 | | public int Max { get; private set; } = 10; |
| | 27 | |
|
| | 28 | | #region Constructors |
| | 29 | |
|
| | 30 | | /// <summary>Default constructor for Json serialization.</summary> |
| 1 | 31 | | public ResultsSet() |
| 2 | 32 | | { } |
| | 33 | |
|
| | 34 | | /// <summary>Initializes a new instance of the ResultsSet class.</summary> |
| | 35 | | /// <param name="max">Maximum numbers of results to return.</param> |
| 3 | 36 | | public ResultsSet( int? max = 0 ) |
| 3 | 37 | | { |
| 6 | 38 | | if( max is not null and > 0 ) { Max = max.Value; } |
| 3 | 39 | | } |
| | 40 | |
|
| | 41 | | #endregion |
| | 42 | | } |