Table of Contents

Class ThrowIf

Namespace
Glitch9

Validate objects and throw exceptions when a condition is not met.

public class ThrowIf
Inheritance
ThrowIf
Inherited Members
Extension Methods

Methods

ArgumentIsNull(object, string)

Throws ArgumentNullException if the value is null.

public static void ArgumentIsNull(object value, string paramName)

Parameters

value object

The value to check.

paramName string

The name of the parameter.

Exceptions

ArgumentNullException

ArgumentIsNull(params (object value, string name)[])

public static void ArgumentIsNull(params (object value, string name)[] values)

Parameters

values (object value, string name)[]

ArgumentIsNull<T>(T)

Throws ArgumentNullException if the value is null.

public static void ArgumentIsNull<T>(T value)

Parameters

value T

The value to check.

Type Parameters

T

The type of the value.

Exceptions

ArgumentNullException

CollectionIsNullOrEmpty<T>(ICollection<T>, string)

public static void CollectionIsNullOrEmpty<T>(ICollection<T> collection, string collectionName = "Collection")

Parameters

collection ICollection<T>
collectionName string

Type Parameters

T

EndpointIsNull(string, string)

public static void EndpointIsNull(string value, string endpointName = "Endpoint")

Parameters

value string
endpointName string

InsufficientCurrency(float, float, string)

public static void InsufficientCurrency(float balance, float amount, string currencyName = "Funds")

Parameters

balance float
amount float
currencyName string

IsDefault<T>(T, string)

public static void IsDefault<T>(T value, string paramName)

Parameters

value T
paramName string

Type Parameters

T

IsLessThanZero(decimal, string)

public static void IsLessThanZero(decimal value, string paramName)

Parameters

value decimal
paramName string

IsLessThanZero(double, string)

public static void IsLessThanZero(double value, string paramName)

Parameters

value double
paramName string

IsLessThanZero(int, string)

public static void IsLessThanZero(int value, string paramName)

Parameters

value int
paramName string

IsLessThanZero(long, string)

public static void IsLessThanZero(long value, string paramName)

Parameters

value long
paramName string

IsLessThanZero(float, string)

public static void IsLessThanZero(float value, string paramName)

Parameters

value float
paramName string

IsNullOrEmpty(string, string)

Throws ArgumentNullException if the string is null or empty.

public static void IsNullOrEmpty(string value, string paramName)

Parameters

value string

The value to check.

paramName string

The name of the parameter.

Exceptions

ArgumentNullException

IsNullOrEmpty<T>(ICollection<T>, string)

public static void IsNullOrEmpty<T>(ICollection<T> value, string paramName)

Parameters

value ICollection<T>
paramName string

Type Parameters

T

IsNullOrWhitespace(string, string)

Throws ArgumentNullException if the string is null or whitespace.

public static void IsNullOrWhitespace(string value, string paramName)

Parameters

value string

The value to check.

paramName string

The name of the parameter.

Exceptions

ArgumentNullException

ListIsNullOrEmpty<T>(IList<T>, string)

public static void ListIsNullOrEmpty<T>(IList<T> array, string arrayName = "Array")

Parameters

array IList<T>
arrayName string

Type Parameters

T

ResultIsNull<T>(T)

public static void ResultIsNull<T>(T result)

Parameters

result T

Type Parameters

T