Class Check
Provides static methods for checking arguments and values.
Inherited Members
Namespace: Innovt.Core.Utilities
Assembly: Innovt.Core.dll
Syntax
public static class Check
Methods
| Edit this page View SourceAreEqual(decimal, decimal, string)
Checks if two decimal values are equal; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreEqual(decimal value, decimal value2, string message)
Parameters
Type | Name | Description |
---|---|---|
decimal | value | The first decimal value to compare. |
decimal | value2 | The second decimal value to compare. |
string | message | The message to include in the exception if the values are not equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the two decimal values are not equal. |
AreEqual(int, int, string)
Checks if two long values are equal; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreEqual(int value, int value2, string message)
Parameters
Type | Name | Description |
---|---|---|
int | value | The first long value to compare. |
int | value2 | The second long value to compare. |
string | message | The message for the exception if the values are not equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the values are not equal, with the specified message. |
AreEqual(long, long, string)
Checks if two decimal values are equal; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreEqual(long value, long value2, string message)
Parameters
Type | Name | Description |
---|---|---|
long | value | The first decimal value to compare. |
long | value2 | The second decimal value to compare. |
string | message | The message for the exception if the values are not equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the values are not equal, with the specified message. |
AreEqual(string, string, string)
Checks if two integer values are equal; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreEqual(string value, string value2, string message)
Parameters
Type | Name | Description |
---|---|---|
string | value | The first integer value to compare. |
string | value2 | The second integer value to compare. |
string | message | The message for the exception if the values are not equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the values are not equal, with the specified message. |
AreNotEqual(int, int, string)
Checks if two integer values are not equal; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreNotEqual(int value, int value2, string message)
Parameters
Type | Name | Description |
---|---|---|
int | value | The first integer value to compare. |
int | value2 | The second integer value to compare. |
string | message | The message for the exception if the values are equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the values are equal, with the specified message. |
AreNotEqual(long, long, string)
Checks if two long values are not equal; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreNotEqual(long value, long value2, string message)
Parameters
Type | Name | Description |
---|---|---|
long | value | The first long value to compare. |
long | value2 | The second long value to compare. |
string | message | The message for the exception if the values are equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the values are equal, with the specified message. |
AreNotEqual(string, string, string)
Checks if two strings are not equal while ignoring case sensitivity; otherwise, throws a BusinessException with the specified message.
Declaration
public static void AreNotEqual(string value, string value2, string message)
Parameters
Type | Name | Description |
---|---|---|
string | value | The first string to compare. |
string | value2 | The second string to compare. |
string | message | The message for the exception if the strings are equal. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the strings are equal, ignoring case sensitivity, with the specified message. |
NotEmpty(string, string)
Checks if the specified string is not null and not empty; otherwise, throws an ArgumentNullException or ArgumentException.
Declaration
public static string NotEmpty(string value, string parameterName = null)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string to check for null and emptiness. |
string | parameterName | The name of the parameter associated with the string. |
Returns
Type | Description |
---|---|
string | The original string if it is not null and not empty. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the string is null. |
ArgumentException | Thrown if the string is empty. |
NotEmpty<T>(IReadOnlyList<T>, string)
Checks if the specified collection is not null and not empty; otherwise, throws an ArgumentException .
Declaration
public static IReadOnlyList<T> NotEmpty<T>(IReadOnlyList<T> value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<T> | value | The collection to check for null and emptiness. |
string | parameterName | The name of the parameter associated with the collection. |
Returns
Type | Description |
---|---|
IReadOnlyList<T> | The original collection if it is not null and not empty. |
Type Parameters
Name | Description |
---|---|
T | The type of the collection elements. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the collection is null. |
ArgumentException | Thrown if the collection is empty. |
NotLessThanZero(int, string)
Checks if the specified integer value is greater than zero; otherwise, throws a BusinessException.
Declaration
public static int NotLessThanZero(int value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
int | value | The integer value to check. |
string | parameterName | The name of the parameter associated with the value. |
Returns
Type | Description |
---|---|
int | Zero if the value is greater than zero. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the value is less than or equal to zero. |
NotLessThanZero(int?, string)
Checks if the specified nullable integer value is greater than zero; otherwise, throws a BusinessException.
Declaration
public static int NotLessThanZero(int? value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
int? | value | The nullable integer value to check. |
string | parameterName | The name of the parameter associated with the value. |
Returns
Type | Description |
---|---|
int | Zero if the value is greater than zero. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the value is less than or equal to zero. |
NotLessThanZero<T>(params T[])
Checks if the specified array of integers are greater than zero; otherwise, throws a BusinessException.
Declaration
public static void NotLessThanZero<T>(params T[] value)
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The array of values to check. |
Type Parameters
Name | Description |
---|---|
T | The type of the array elements, which must be convertible to an integer. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if any of the values is less than or equal to zero. |
NotNullWithBusinessException<T>(T, string)
Checks if the specified value is not null; otherwise, throws a BusinessException with the specified message.
Declaration
public static T NotNullWithBusinessException<T>(T value, string message)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to check for null. |
string | message | The message for the exception if the value is null. |
Returns
Type | Description |
---|---|
T | The original value if it is not null. |
Type Parameters
Name | Description |
---|---|
T | The type of the value to check. |
Exceptions
Type | Condition |
---|---|
BusinessException | Thrown if the value is null, with the specified message. |
NotNullWithCriticalException<T>(T, string)
Checks if the specified value is not null; otherwise, throws a CriticalException with the specified message.
Declaration
public static T NotNullWithCriticalException<T>(T value, string message)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to check for null. |
string | message | The message for the exception if the value is null. |
Returns
Type | Description |
---|---|
T | The original value if it is not null. |
Type Parameters
Name | Description |
---|---|
T | The type of the value to check. |
Exceptions
Type | Condition |
---|---|
CriticalException | Thrown if the value is null, with the specified message. |
NotNull<T>(T, string)
Checks if the specified value is not null; otherwise, throws an ArgumentNullException.
Declaration
public static T NotNull<T>(T value, string parameterName = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to check for null. |
string | parameterName | The name of the parameter associated with the value. |
Returns
Type | Description |
---|---|
T | The original value if it is not null. |
Type Parameters
Name | Description |
---|---|
T | The type of the value to check. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the value is null. |
NullButNotEmpty(string, string)
Checks if the specified string is null but not empty; otherwise, throws an ArgumentException.
Declaration
public static string NullButNotEmpty(string value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string to check for null but not emptiness. |
string | parameterName | The name of the parameter associated with the string. |
Returns
Type | Description |
---|---|
string | The original string if it is not null but not empty. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the string is null or empty. |