From 5ff3184c301d382f6be528486bdd3139ef2ee2ff Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 23 Apr 2017 21:59:54 -0400 Subject: [PATCH] add version.IsBetween method (#263) --- src/StardewModdingAPI/ISemanticVersion.cs | 5 +++++ src/StardewModdingAPI/SemanticVersion.cs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/StardewModdingAPI/ISemanticVersion.cs b/src/StardewModdingAPI/ISemanticVersion.cs index 3b9bdb44..24e6442a 100644 --- a/src/StardewModdingAPI/ISemanticVersion.cs +++ b/src/StardewModdingAPI/ISemanticVersion.cs @@ -32,6 +32,11 @@ namespace StardewModdingAPI /// The version to compare with this instance. bool IsNewerThan(ISemanticVersion other); + /// Get whether this version is between two specified versions (inclusively). + /// The minimum version. + /// The maximum version. + bool IsBetween(ISemanticVersion min, ISemanticVersion max); + /// Get a string representation of the version. string ToString(); } diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs index 9610562f..f6bfb04d 100644 --- a/src/StardewModdingAPI/SemanticVersion.cs +++ b/src/StardewModdingAPI/SemanticVersion.cs @@ -134,6 +134,14 @@ namespace StardewModdingAPI return this.CompareTo(other) > 0; } + /// Get whether this version is between two specified versions (inclusively). + /// The minimum version. + /// The maximum version. + public bool IsBetween(ISemanticVersion min, ISemanticVersion max) + { + return this.CompareTo(min) >= 0 && this.CompareTo(max) <= 0; + } + /// Get a string representation of the version. public override string ToString() {