add version.IsBetween method (#263)

This commit is contained in:
Jesse Plamondon-Willard 2017-04-23 21:59:54 -04:00
parent 01917e70a2
commit 5ff3184c30
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,11 @@ namespace StardewModdingAPI
/// <param name="other">The version to compare with this instance.</param> /// <param name="other">The version to compare with this instance.</param>
bool IsNewerThan(ISemanticVersion other); 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> /// <summary>Get a string representation of the version.</summary>
string ToString(); string ToString();
} }

View File

@ -134,6 +134,14 @@ namespace StardewModdingAPI
return this.CompareTo(other) > 0; 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> /// <summary>Get a string representation of the version.</summary>
public override string ToString() public override string ToString()
{ {