mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-13 00:15:42 +00:00
(#42) Validate lower <= upper
This commit is contained in:
parent
370f2d96f4
commit
d6f4a96257
@ -45,12 +45,21 @@ namespace X10D
|
|||||||
/// </example>
|
/// </example>
|
||||||
public static bool Between<T1, T2, T3>(this T1 value, T2 lower, T3 upper)
|
public static bool Between<T1, T2, T3>(this T1 value, T2 lower, T3 upper)
|
||||||
where T1 : IComparable<T2>, IComparable<T3>
|
where T1 : IComparable<T2>, IComparable<T3>
|
||||||
|
where T2 : IComparable<T3>
|
||||||
|
where T3 : IComparable<T2>
|
||||||
{
|
{
|
||||||
if (value is null)
|
if (value is null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(value));
|
throw new ArgumentNullException(nameof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lower.GreaterThan(upper))
|
||||||
|
{
|
||||||
|
throw new ArgumentException(
|
||||||
|
string.Format(ExceptionMessages.LowerCannotBeGreaterThanUpper, lower, upper),
|
||||||
|
nameof(lower));
|
||||||
|
}
|
||||||
|
|
||||||
return value.CompareTo(lower) > 0 && value.CompareTo(upper) < 0;
|
return value.CompareTo(lower) > 0 && value.CompareTo(upper) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user