blob: 2eca30dfc781da86691287c9e1f549f4976f2a69 (
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
|
using System.Collections.Generic;
namespace StardewModdingAPI.Toolkit
{
/// <summary>A comparer for semantic versions based on the <see cref="SemanticVersion.CompareTo(ISemanticVersion)"/> field.</summary>
public class SemanticVersionComparer : IComparer<ISemanticVersion?>
{
/*********
** Accessors
*********/
/// <summary>A singleton instance of the comparer.</summary>
public static SemanticVersionComparer Instance { get; } = new();
/*********
** Public methods
*********/
/// <inheritdoc />
public int Compare(ISemanticVersion? x, ISemanticVersion? y)
{
if (object.ReferenceEquals(x, y))
return 0;
if (x is null)
return -1;
if (y is null)
return 1;
return x.CompareTo(y);
}
}
}
|