-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathOLWorkData.cs
More file actions
79 lines (74 loc) · 2.52 KB
/
OLWorkData.cs
File metadata and controls
79 lines (74 loc) · 2.52 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
75
76
77
78
79
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using OpenLibraryNET.Utility;
using CodeGeneration_Attributes;
namespace OpenLibraryNET.Data
{
/// <summary>
/// Holds data about a work.
/// </summary>
[CollectionValueEquality]
public partial record OLWorkData : OLContainer
{
/// <summary>
/// The ID of the work.
/// </summary>
[JsonIgnore]
public string ID => OpenLibraryUtility.ExtractIdFromKey(Key);
/// <summary>
/// The key of the work.
/// </summary>
[JsonProperty("key")]
public string Key { get; init; } = "";
/// <summary>
/// The title of the work.
/// </summary>
[JsonProperty("title")]
public string Title { get; init; } = "";
/// <summary>
/// The work's description.
/// </summary>
[JsonProperty("description")]
[JsonConverter(typeof(OpenLibraryUtility.Serialization.DescriptionConverter))]
public string Description { get; init; } = "";
/// <summary>
/// The work's associated subjects.
/// </summary>
[JsonIgnore]
public IReadOnlyList<string> Subjects
{
get => new ReadOnlyCollection<string>(_subjects);
init => _subjects = value.ToArray();
}
/// <summary>
/// The keys of the authors of the work.
/// </summary>
[JsonIgnore]
public IReadOnlyList<string> AuthorKeys
{
get => new ReadOnlyCollection<string>(_authors);
init => _authors = value.ToArray();
}
/// <summary>
/// The IDs of the covers of the work.
/// </summary>
[JsonIgnore]
public IReadOnlyList<int> CoverIDs
{
get => new ReadOnlyCollection<int>(_coverKeys);
init => _coverKeys = value.ToArray();
}
[JsonProperty("subjects")]
private string[] _subjects { get; init; } = Array.Empty<string>();
[JsonProperty("authors")]
[JsonConverter(typeof(OpenLibraryUtility.Serialization.AuthorsKeysConverter))]
private string[] _authors { get; init; } = Array.Empty<string>();
[JsonProperty("covers")]
private int[] _coverKeys { get; init; } = Array.Empty<int>();
// Aliases
[JsonProperty("subject")]
private string[] _subjectsSubjects { init => _subjects = value; }
//[JsonProperty("cover_id")]
//private int subjectsCover { init => coverKeys.Add(value); }
}
}