mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:25:41 +00:00
(#42) Validate not-null values
This commit is contained in:
parent
d6f4a96257
commit
e2e7b3a947
@ -125,6 +125,11 @@ namespace X10D
|
|||||||
public static bool GreaterThan<T1, T2>(this T1 value, T2 other)
|
public static bool GreaterThan<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return value.CompareTo(other) > 0;
|
return value.CompareTo(other) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +157,11 @@ namespace X10D
|
|||||||
public static bool GreaterThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
public static bool GreaterThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return value.CompareTo(other) >= 0;
|
return value.CompareTo(other) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +189,11 @@ namespace X10D
|
|||||||
public static bool LessThan<T1, T2>(this T1 value, T2 other)
|
public static bool LessThan<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return value.CompareTo(other) < 0;
|
return value.CompareTo(other) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +221,11 @@ namespace X10D
|
|||||||
public static bool LessThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
public static bool LessThanOrEqualTo<T1, T2>(this T1 value, T2 other)
|
||||||
where T1 : IComparable<T2>
|
where T1 : IComparable<T2>
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return value.CompareTo(other) <= 0;
|
return value.CompareTo(other) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +252,11 @@ namespace X10D
|
|||||||
public static T Max<T>(this T value, T other)
|
public static T Max<T>(this T value, T other)
|
||||||
where T : IComparable<T>
|
where T : IComparable<T>
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return value.GreaterThan(other) ? value : other;
|
return value.GreaterThan(other) ? value : other;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +283,11 @@ namespace X10D
|
|||||||
public static T Min<T>(this T value, T other)
|
public static T Min<T>(this T value, T other)
|
||||||
where T : IComparable<T>
|
where T : IComparable<T>
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return value.LessThan(other) ? value : other;
|
return value.LessThan(other) ? value : other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user