ContentfulCollection.cs
2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Contentful.Core.Models
{
/// <summary>
/// Represents a collection of contentful resources with additional medadata regarding, skip, limit and total amount of items.
/// </summary>
/// <typeparam name="T">The type to serialize the items array from the API response into.</typeparam>
[JsonObject]
public class ContentfulCollection<T> : IEnumerable<T>
{
/// <summary>
/// Common system managed metadata properties.
/// </summary>
[JsonProperty("sys")]
public SystemProperties SystemProperties { get; set; }
/// <summary>
/// The number of items skipped in this resultset.
/// </summary>
public int Skip { get; set; }
/// <summary>
/// The maximum number of items returned in this result.
/// </summary>
public int Limit { get; set; }
/// <summary>
/// The total number of items available.
/// </summary>
public int Total { get; set; }
/// <summary>
/// The <see cref="IEnumerable{T}"/> of items to be serialized from the API response.
/// </summary>
public IEnumerable<T> Items { get; set; }
/// <summary>
/// The <see cref="IEnumerable{Entry}" /> of included referenced entries
/// </summary>
public IEnumerable<Entry<dynamic>> IncludedEntries { get; set; }
/// <summary>
/// The <see cref="IEnumerable{Asset}" /> of included referenced assets
/// </summary>
public IEnumerable<Asset> IncludedAssets { get; set; }
/// <summary>
/// An enumerable of errors while deserializing. Will be null if no errors are present.
/// </summary>
public IEnumerable<ContentfulError> Errors { get; set; }
/// <summary>
/// Returns an enumerator that iterates through the <see cref="Items"/> collection
/// </summary>
public IEnumerator<T> GetEnumerator()
{
return Items.GetEnumerator();
}
/// <summary>
/// Returns an enumerator that iterates through the <see cref="Items"/> collection
/// </summary>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}