diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-23 21:59:54 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-23 21:59:54 -0400 |
commit | 5ff3184c301d382f6be528486bdd3139ef2ee2ff (patch) | |
tree | 9218311b6e4e127425d1b3d939a96b7651aedec2 /src/StardewModdingAPI | |
parent | 01917e70a28a4a9028417d1784ef7f2ab06869a7 (diff) | |
download | SMAPI-5ff3184c301d382f6be528486bdd3139ef2ee2ff.tar.gz SMAPI-5ff3184c301d382f6be528486bdd3139ef2ee2ff.tar.bz2 SMAPI-5ff3184c301d382f6be528486bdd3139ef2ee2ff.zip |
add version.IsBetween method (#263)
Diffstat (limited to 'src/StardewModdingAPI')
-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() { |