diff options
-rw-r--r-- | src/StardewModdingAPI/ISemanticVersion.cs | 5 | ||||
-rw-r--r-- | src/StardewModdingAPI/SemanticVersion.cs | 8 |
2 files changed, 13 insertions, 0 deletions
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 /// <param name="other">The version to compare with this instance.</param> bool IsNewerThan(ISemanticVersion other); + /// <summary>Get whether this version is between two specified versions (inclusively).</summary> + /// <param name="min">The minimum version.</param> + /// <param name="max">The maximum version.</param> + bool IsBetween(ISemanticVersion min, ISemanticVersion max); + /// <summary>Get a string representation of the version.</summary> 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; } + /// <summary>Get whether this version is between two specified versions (inclusively).</summary> + /// <param name="min">The minimum version.</param> + /// <param name="max">The maximum version.</param> + public bool IsBetween(ISemanticVersion min, ISemanticVersion max) + { + return this.CompareTo(min) >= 0 && this.CompareTo(max) <= 0; + } + /// <summary>Get a string representation of the version.</summary> public override string ToString() { |