-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathListObject.cs
More file actions
32 lines (28 loc) · 976 Bytes
/
ListObject.cs
File metadata and controls
32 lines (28 loc) · 976 Bytes
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
#nullable enable
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Altinn.Register.Models;
/// <summary>
/// A list object is a wrapper around a list of items to allow for the API to be
/// extended in the future without breaking backwards compatibility.
/// </summary>
public abstract record ListObject
{
/// <summary>
/// Creates a new <see cref="ListObject{T}"/> from a list of items.
/// </summary>
/// <typeparam name="T">The list type.</typeparam>
/// <param name="items">The list of items.</param>
/// <returns>A <see cref="ListObject{T}"/>.</returns>
public static ListObject<T> Create<T>(IEnumerable<T> items)
=> new(items);
}
/// <summary>
/// A concrete list object.
/// </summary>
/// <typeparam name="T">The item type.</typeparam>
/// <param name="Items">The items.</param>
public record ListObject<T>(
[property: JsonPropertyName("data")]
IEnumerable<T> Items)
: ListObject;