blob: f3f22b93885a39fca058ca9f0246147898688262 (
plain)
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
|
using System;
using Newtonsoft.Json;
namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
{
/// <summary>Metadata about a mod.</summary>
public class ModEntryModel
{
/*********
** Accessors
*********/
/// <summary>The mod's unique ID (if known).</summary>
public string ID { get; set; }
/// <summary>The main version.</summary>
public ModEntryVersionModel Main { get; set; }
/// <summary>The latest optional version, if newer than <see cref="Main"/>.</summary>
public ModEntryVersionModel Optional { get; set; }
/// <summary>The latest unofficial version, if newer than <see cref="Main"/> and <see cref="Optional"/>.</summary>
public ModEntryVersionModel Unofficial { get; set; }
/// <summary>Optional extended data which isn't needed for update checks.</summary>
public ModExtendedMetadataModel Metadata { get; set; }
/// <summary>The errors that occurred while fetching update data.</summary>
public string[] Errors { get; set; } = new string[0];
/****
** Backwards-compatible fields
****/
/// <summary>The mod's latest version number.</summary>
[Obsolete("Use " + nameof(ModEntryModel.Main))]
[JsonProperty]
internal string Version { get; private set; }
/// <summary>The mod's web URL.</summary>
[Obsolete("Use " + nameof(ModEntryModel.Main))]
[JsonProperty]
internal string Url { get; private set; }
/// <summary>The mod's latest optional release, if newer than <see cref="Version"/>.</summary>
[Obsolete("Use " + nameof(ModEntryModel.Optional))]
[JsonProperty]
internal string PreviewVersion { get; private set; }
/// <summary>The web URL to the mod's latest optional release, if newer than <see cref="Version"/>.</summary>
[Obsolete("Use " + nameof(ModEntryModel.Optional))]
[JsonProperty]
internal string PreviewUrl { get; private set; }
/*********
** Public methods
*********/
/// <summary>Set backwards-compatible fields.</summary>
/// <param name="version">The requested API version.</param>
public void SetBackwardsCompatibility(ISemanticVersion version)
{
if (version.IsOlderThan("2.6-beta.19"))
{
this.Version = this.Main?.Version?.ToString();
this.Url = this.Main?.Url;
this.PreviewVersion = this.Optional?.Version?.ToString();
this.PreviewUrl = this.Optional?.Url;
}
}
}
}
|