diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-19 21:21:57 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-25 18:20:15 -0400 |
commit | 26a629f41b98faafed8af38a89f25d9b821fac0f (patch) | |
tree | d99ac9a40b18f55c6969d4ee6f2638fae44ac524 /src/SMAPI.Toolkit | |
parent | 596a4616b343bc527c0a90df0f0be0ece970c3c7 (diff) | |
download | SMAPI-26a629f41b98faafed8af38a89f25d9b821fac0f.tar.gz SMAPI-26a629f41b98faafed8af38a89f25d9b821fac0f.tar.bz2 SMAPI-26a629f41b98faafed8af38a89f25d9b821fac0f.zip |
fix prerelease update alerts shown for non-prerelease players
Diffstat (limited to 'src/SMAPI.Toolkit')
-rw-r--r-- | src/SMAPI.Toolkit/SemanticVersionComparer.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/SMAPI.Toolkit/SemanticVersionComparer.cs b/src/SMAPI.Toolkit/SemanticVersionComparer.cs new file mode 100644 index 00000000..9f6b57a2 --- /dev/null +++ b/src/SMAPI.Toolkit/SemanticVersionComparer.cs @@ -0,0 +1,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); + } + } +} |