blob: 9f6b57a25b38fefd7d5f068a677c60da3d8c5292 (
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 SemanticVersionComparer();
/*********
** 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);
}
}
}
|