Class Validator
Provides a generic way to validate different types of arguments passed to members.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class Validator
Methods
| Improve this DocThrowIf(Func<Boolean>, Func<String, String, Exception>, String, String)
Validates from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf(Func<bool> condition, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Boolean> | condition | The function delegate that determines if an |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIf<TValue>(TValue, Func<TValue, Boolean>, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf<TValue>(TValue value, Func<TValue, bool> condition, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, System.Boolean> | condition | The function delegate that determines if an |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIf<TValue, T>(TValue, Func<TValue, T, Boolean>, T, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf<TValue, T>(TValue value, Func<TValue, T, bool> condition, T arg, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T, System.Boolean> | condition | The function delegate that determines if an |
| T | arg | The parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T | The type of the parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIf<TValue, T1, T2>(TValue, Func<TValue, T1, T2, Boolean>, T1, T2, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf<TValue, T1, T2>(TValue value, Func<TValue, T1, T2, bool> condition, T1 arg1, T2 arg2, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIf<TValue, T1, T2, T3>(TValue, Func<TValue, T1, T2, T3, Boolean>, T1, T2, T3, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf<TValue, T1, T2, T3>(TValue value, Func<TValue, T1, T2, T3, bool> condition, T1 arg1, T2 arg2, T3 arg3, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, T3, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIf<TValue, T1, T2, T3, T4>(TValue, Func<TValue, T1, T2, T3, T4, Boolean>, T1, T2, T3, T4, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf<TValue, T1, T2, T3, T4>(TValue value, Func<TValue, T1, T2, T3, T4, bool> condition, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, T3, T4, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIf<TValue, T1, T2, T3, T4, T5>(TValue, Func<TValue, T1, T2, T3, T4, T5, Boolean>, T1, T2, T3, T4, T5, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates true.
Declaration
public static void ThrowIf<TValue, T1, T2, T3, T4, T5>(TValue value, Func<TValue, T1, T2, T3, T4, T5, bool> condition, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, T3, T4, T5, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
| T5 | arg5 | The fifth parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
| T5 | The type of the fifth parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfContainsType(Object, String, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is contained within at least one of the specified types.
Declaration
public static void ThrowIfContainsType(object value, string paramName, string message, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfContainsType(Object, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is contained within at least one of the specified types.
Declaration
public static void ThrowIfContainsType(object value, string paramName, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfContainsType(Type, String, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is contained within at least one of the specified types.
Declaration
public static void ThrowIfContainsType(Type value, string paramName, string message, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfContainsType(Type, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is contained within at least one of the specified types.
Declaration
public static void ThrowIfContainsType(Type value, string paramName, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfContainsType<T>(String, String, Type[])
Validates and throws an TypeArgumentOutOfRangeException if the specified T is contained within at least one of the specified types.
Declaration
public static void ThrowIfContainsType<T>(string typeParamName, string message, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| TypeArgumentOutOfRangeException |
|
ThrowIfContainsType<T>(String, Type[])
Validates and throws an TypeArgumentOutOfRangeException if the specified T is contained within at least one of the specified types.
Declaration
public static void ThrowIfContainsType<T>(string typeParamName, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| TypeArgumentOutOfRangeException |
|
ThrowIfDistinctDifference(String, String, String, String)
Validates and throws an System.ArgumentOutOfRangeException if there is a distinct difference between arbitrary and definite.
Declaration
public static void ThrowIfDistinctDifference(string definite, string arbitrary, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | definite | The value that specifies valid characters. |
| System.String | arbitrary | The value to distinctively compare with |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | There is a distinct difference between |
ThrowIfEmailAddress(String, String)
Validates and throws an System.ArgumentException if the specified value has the format of an email address.
Declaration
public static void ThrowIfEmailAddress(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfEmailAddress(String, String, String)
Validates and throws an System.ArgumentException if the specified value has the format of an email address.
Declaration
public static void ThrowIfEmailAddress(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfEmpty(String, String)
Validates and throws an ArgumentEmptyException if the specified value is empty.
Declaration
public static void ThrowIfEmpty(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentEmptyException |
|
ThrowIfEmpty(String, String, String)
Validates and throws an ArgumentEmptyException if the specified value is empty.
Declaration
public static void ThrowIfEmpty(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentEmptyException |
|
ThrowIfEnum<TEnum>(String, Boolean, String)
Validates and throws an System.ArgumentException if the specified value represents an enumeration.
Declaration
public static void ThrowIfEnum<TEnum>(string value, bool ignoreCase, string paramName)
where TEnum : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.Boolean | ignoreCase |
|
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enumeration. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfEnum<TEnum>(String, Boolean, String, String)
Validates and throws an System.ArgumentException if the specified value represents an enumeration.
Declaration
public static void ThrowIfEnum<TEnum>(string value, bool ignoreCase, string paramName, string message)
where TEnum : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.Boolean | ignoreCase |
|
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enumeration. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfEnum<TEnum>(String, String)
Validates and throws an System.ArgumentException if the specified value represents an enumeration.
Declaration
public static void ThrowIfEnum<TEnum>(string value, string paramName)
where TEnum : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enumeration. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfEnumType<TEnum>(String)
Validates and throws an TypeArgumentException if the specified TEnum represents an enumeration.
Declaration
public static void ThrowIfEnumType<TEnum>(string typeParamName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type to check is an enumeration. |
Exceptions
| Type | Condition |
|---|---|
| TypeArgumentException |
|
ThrowIfEnumType<TEnum>(String, String)
Validates and throws an TypeArgumentException if the specified TEnum represents an enumeration.
Declaration
public static void ThrowIfEnumType<TEnum>(string typeParamName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type to check is an enumeration. |
Exceptions
| Type | Condition |
|---|---|
| TypeArgumentException |
|
ThrowIfEqual<T>(T, T, IEqualityComparer<T>, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are equal to the y object.
Declaration
public static void ThrowIfEqual<T>(T x, T y, IEqualityComparer<T> comparer, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.Collections.Generic.IEqualityComparer<T> | comparer | The System.Collections.Generic.IEqualityComparer<T> implementation to use when comparing |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfEqual<T>(T, T, IEqualityComparer<T>, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are equal to the y object.
Declaration
public static void ThrowIfEqual<T>(T x, T y, IEqualityComparer<T> comparer, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.Collections.Generic.IEqualityComparer<T> | comparer | The System.Collections.Generic.IEqualityComparer<T> implementation to use when comparing |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfEqual<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are equal to the y object.
Declaration
public static void ThrowIfEqual<T>(T x, T y, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfEqual<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are equal to the y object.
Declaration
public static void ThrowIfEqual<T>(T x, T y, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfFalse(Boolean, String)
Validates and throws an System.ArgumentException if the specified value is false.
Declaration
public static void ThrowIfFalse(bool value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfFalse(Boolean, String, String)
Validates and throws an System.ArgumentException if the specified value is false.
Declaration
public static void ThrowIfFalse(bool value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfGreaterThan<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is greater than y.
Declaration
public static void ThrowIfGreaterThan<T>(T x, T y, string paramName)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfGreaterThan<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is greater than y.
Declaration
public static void ThrowIfGreaterThan<T>(T x, T y, string paramName, string message)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfGreaterThanOrEqual<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is greater than or equal to y.
Declaration
public static void ThrowIfGreaterThanOrEqual<T>(T x, T y, string paramName)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfGreaterThanOrEqual<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is greater than or equal to y.
Declaration
public static void ThrowIfGreaterThanOrEqual<T>(T x, T y, string paramName, string message)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfGuid(String, GuidFormats, String)
Validates and throws an System.ArgumentException if the specified value has the format of a System.Guid.
Declaration
public static void ThrowIfGuid(string value, GuidFormats format, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| GuidFormats | format | A bitmask comprised of one or more GuidFormats that specify how the GUID parsing is conducted. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfGuid(String, GuidFormats, String, String)
Validates and throws an System.ArgumentException if the specified value has the format of a System.Guid.
Declaration
public static void ThrowIfGuid(string value, GuidFormats format, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| GuidFormats | format | A bitmask comprised of one or more GuidFormats that specify how the GUID parsing is conducted. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfGuid(String, String)
Validates and throws an System.ArgumentException if the specified value has the format of a System.Guid.
Declaration
public static void ThrowIfGuid(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Remarks
This implementation only evaluates for GUID formats of: DigitFormat | BraceFormat | ParenthesisFormat, eg. 32 digits separated by hyphens; 32 digits separated by hyphens, enclosed in brackets and 32 digits separated by hyphens, enclosed in parentheses.
The reason not to include NumberFormat, eg. 32 digits is the possible unintended GUID result of a MD5 string representation.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfHex(String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified value is hexadecimal.
Declaration
public static void ThrowIfHex(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfHex(String, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified value is hexadecimal.
Declaration
public static void ThrowIfHex(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfLowerThan<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is lower than y.
Declaration
public static void ThrowIfLowerThan<T>(T x, T y, string paramName)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfLowerThan<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is lower than y.
Declaration
public static void ThrowIfLowerThan<T>(T x, T y, string paramName, string message)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfLowerThanOrEqual<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is lower than or equal to y.
Declaration
public static void ThrowIfLowerThanOrEqual<T>(T x, T y, string paramName)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfLowerThanOrEqual<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x is lower than or equal to y.
Declaration
public static void ThrowIfLowerThanOrEqual<T>(T x, T y, string paramName, string message)
where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNot(Func<Boolean>, Func<String, String, Exception>, String, String)
Validates from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot(Func<bool> condition, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Boolean> | condition | The function delegate that determines if an |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNot<TValue>(TValue, Func<TValue, Boolean>, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot<TValue>(TValue value, Func<TValue, bool> condition, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, System.Boolean> | condition | The function delegate that determines if an |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNot<TValue, T>(TValue, Func<TValue, T, Boolean>, T, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot<TValue, T>(TValue value, Func<TValue, T, bool> condition, T arg, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T, System.Boolean> | condition | The function delegate that determines if an |
| T | arg | The parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T | The type of the parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNot<TValue, T1, T2>(TValue, Func<TValue, T1, T2, Boolean>, T1, T2, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot<TValue, T1, T2>(TValue value, Func<TValue, T1, T2, bool> condition, T1 arg1, T2 arg2, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNot<TValue, T1, T2, T3>(TValue, Func<TValue, T1, T2, T3, Boolean>, T1, T2, T3, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot<TValue, T1, T2, T3>(TValue value, Func<TValue, T1, T2, T3, bool> condition, T1 arg1, T2 arg2, T3 arg3, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, T3, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNot<TValue, T1, T2, T3, T4>(TValue, Func<TValue, T1, T2, T3, T4, Boolean>, T1, T2, T3, T4, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot<TValue, T1, T2, T3, T4>(TValue value, Func<TValue, T1, T2, T3, T4, bool> condition, T1 arg1, T2 arg2, T3 arg3, T4 arg4, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, T3, T4, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNot<TValue, T1, T2, T3, T4, T5>(TValue, Func<TValue, T1, T2, T3, T4, T5, Boolean>, T1, T2, T3, T4, T5, Func<String, String, Exception>, String, String)
Validates the specified value from the provided condition.
An exception is resolved and thrown if the condition evaluates false.
Declaration
public static void ThrowIfNot<TValue, T1, T2, T3, T4, T5>(TValue value, Func<TValue, T1, T2, T3, T4, T5, bool> condition, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, Func<string, string, Exception> exception, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value that will be evaluated by |
| System.Func<TValue, T1, T2, T3, T4, T5, System.Boolean> | condition | The function delegate that determines if an |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
| T5 | arg5 | The fifth parameter of the function delegate |
| System.Func<System.String, System.String, System.Exception> | exception | The function delegate that resolves the System.Exception to be thrown. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the value to evaluate. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
| T5 | The type of the fifth parameter of the function delegate |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNotContainsType(Object, String, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is not contained within at least one of the specified types.
Declaration
public static void ThrowIfNotContainsType(object value, string paramName, string message, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotContainsType(Object, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is not contained within at least one of the specified types.
Declaration
public static void ThrowIfNotContainsType(object value, string paramName, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotContainsType(Type, String, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is not contained within at least one of the specified types.
Declaration
public static void ThrowIfNotContainsType(Type value, string paramName, string message, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotContainsType(Type, String, Type[])
Validates and throws an System.ArgumentOutOfRangeException if the specified value is not contained within at least one of the specified types.
Declaration
public static void ThrowIfNotContainsType(Type value, string paramName, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotContainsType<T>(String, String, Type[])
Validates and throws an TypeArgumentOutOfRangeException if the specified T is not contained within at least one of the specified types.
Declaration
public static void ThrowIfNotContainsType<T>(string typeParamName, string message, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| TypeArgumentOutOfRangeException |
|
ThrowIfNotContainsType<T>(String, Type[])
Validates and throws an TypeArgumentOutOfRangeException if the specified T is not contained within at least one of the specified types.
Declaration
public static void ThrowIfNotContainsType<T>(string typeParamName, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
| System.Type[] | types | A variable number of System.Type arguments to match with the type of |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| TypeArgumentOutOfRangeException |
|
ThrowIfNotDistinctDifference(String, String, String, String)
Validates and throws an System.ArgumentOutOfRangeException if there is not a distinct difference between arbitrary and definite.
Declaration
public static void ThrowIfNotDistinctDifference(string definite, string arbitrary, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | definite | The value that specifies valid characters. |
| System.String | arbitrary | The value to distinctively compare with |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | There is not a distinct difference between |
ThrowIfNotEmailAddress(String, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of an email address.
Declaration
public static void ThrowIfNotEmailAddress(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotEmailAddress(String, String, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of an email address.
Declaration
public static void ThrowIfNotEmailAddress(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotEnum<TEnum>(String, Boolean, String)
Validates and throws an System.ArgumentException if the specified value does not represents an enumeration.
Declaration
public static void ThrowIfNotEnum<TEnum>(string value, bool ignoreCase, string paramName)
where TEnum : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.Boolean | ignoreCase |
|
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enumeration. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotEnum<TEnum>(String, Boolean, String, String)
Validates and throws an System.ArgumentException if the specified value does not represents an enumeration.
Declaration
public static void ThrowIfNotEnum<TEnum>(string value, bool ignoreCase, string paramName, string message)
where TEnum : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.Boolean | ignoreCase |
|
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enumeration. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotEnum<TEnum>(String, String)
Validates and throws an System.ArgumentException if the specified value does not represents an enumeration.
Declaration
public static void ThrowIfNotEnum<TEnum>(string value, string paramName)
where TEnum : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enumeration. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotEnumType<TEnum>(String)
Validates and throws an TypeArgumentException if the specified TEnum does not represents an enumeration.
Declaration
public static void ThrowIfNotEnumType<TEnum>(string typeParamName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type to check is not an enumeration. |
Exceptions
| Type | Condition |
|---|---|
| TypeArgumentException |
|
ThrowIfNotEnumType<TEnum>(String, String)
Validates and throws an TypeArgumentException if the specified TEnum does not represents an enumeration.
Declaration
public static void ThrowIfNotEnumType<TEnum>(string typeParamName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeParamName | The name of the type parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type to check is not an enumeration. |
Exceptions
| Type | Condition |
|---|---|
| TypeArgumentException |
|
ThrowIfNotEqual<T>(T, T, IEqualityComparer<T>, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are not equal to the y object.
Declaration
public static void ThrowIfNotEqual<T>(T x, T y, IEqualityComparer<T> comparer, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.Collections.Generic.IEqualityComparer<T> | comparer | The System.Collections.Generic.IEqualityComparer<T> implementation to use when comparing |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotEqual<T>(T, T, IEqualityComparer<T>, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are not equal to the y object.
Declaration
public static void ThrowIfNotEqual<T>(T x, T y, IEqualityComparer<T> comparer, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.Collections.Generic.IEqualityComparer<T> | comparer | The System.Collections.Generic.IEqualityComparer<T> implementation to use when comparing |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotEqual<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are not equal to the y object.
Declaration
public static void ThrowIfNotEqual<T>(T x, T y, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotEqual<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are not equal to the y object.
Declaration
public static void ThrowIfNotEqual<T>(T x, T y, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotGuid(String, GuidFormats, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of a System.Guid.
Declaration
public static void ThrowIfNotGuid(string value, GuidFormats format, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| GuidFormats | format | A bitmask comprised of one or more GuidFormats that specify how the GUID parsing is conducted. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotGuid(String, GuidFormats, String, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of a System.Guid.
Declaration
public static void ThrowIfNotGuid(string value, GuidFormats format, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| GuidFormats | format | A bitmask comprised of one or more GuidFormats that specify how the GUID parsing is conducted. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotGuid(String, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of a System.Guid.
Declaration
public static void ThrowIfNotGuid(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Remarks
This implementation only evaluates for GUID formats of: DigitFormat | BraceFormat | ParenthesisFormat, eg. 32 digits separated by hyphens; 32 digits separated by hyphens, enclosed in brackets and 32 digits separated by hyphens, enclosed in parentheses.
The reason not to include NumberFormat, eg. 32 digits is the possible unintended GUID result of a MD5 string representation.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotHex(String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified value is not hexadecimal.
Declaration
public static void ThrowIfNotHex(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotHex(String, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified value is not hexadecimal.
Declaration
public static void ThrowIfNotHex(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotNumber(String, String)
Validates and throws an System.ArgumentException if the specified value is not a number.
Declaration
public static void ThrowIfNotNumber(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotNumber(String, String, NumberStyles)
Validates and throws an System.ArgumentException if the specified value is not a number.
Declaration
public static void ThrowIfNotNumber(string value, string paramName, NumberStyles styles)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotNumber(String, String, NumberStyles, IFormatProvider)
Validates and throws an System.ArgumentException if the specified value is not a number.
Declaration
public static void ThrowIfNotNumber(string value, string paramName, NumberStyles styles, IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
| System.IFormatProvider | provider | An System.IFormatProvider that supplies culture-specific formatting information about |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotNumber(String, String, String)
Validates and throws an System.ArgumentException if the specified value is not a number.
Declaration
public static void ThrowIfNotNumber(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotNumber(String, String, String, NumberStyles)
Validates and throws an System.ArgumentException if the specified value is not a number.
Declaration
public static void ThrowIfNotNumber(string value, string paramName, string message, NumberStyles styles)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotNumber(String, String, String, NumberStyles, IFormatProvider)
Validates and throws an System.ArgumentException if the specified value is not a number.
Declaration
public static void ThrowIfNotNumber(string value, string paramName, string message, NumberStyles styles, IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
| System.IFormatProvider | provider | An System.IFormatProvider that supplies culture-specific formatting information about |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotSame<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are not of the same instance as the y object.
Declaration
public static void ThrowIfNotSame<T>(T x, T y, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotSame<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are not of the same instance as the y object.
Declaration
public static void ThrowIfNotSame<T>(T x, T y, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfNotUri(String, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of an System.Uri.
Declaration
public static void ThrowIfNotUri(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNotUri(String, UriKind, String, String)
Validates and throws an System.ArgumentException if the specified value does not have the format of an System.Uri.
Declaration
public static void ThrowIfNotUri(string value, UriKind uriKind, string paramName, string message = "Value must be an URI.")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.UriKind | uriKind | The type of the URI. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNull<T>(T, String)
Validates and throws an System.ArgumentNullException if the specified value is null.
Declaration
public static void ThrowIfNull<T>(T value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNull<T>(T, String, String)
Validates and throws an System.ArgumentNullException if the specified value is null.
Declaration
public static void ThrowIfNull<T>(T value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ThrowIfNullOrEmpty(String, String)
Validates and throws either an System.ArgumentNullException or ArgumentEmptyException if the specified value is respectively null or empty.
Declaration
public static void ThrowIfNullOrEmpty(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| ArgumentEmptyException |
|
ThrowIfNullOrEmpty(String, String, String)
Validates and throws either an System.ArgumentNullException or ArgumentEmptyException if the specified value is respectively null or empty.
Declaration
public static void ThrowIfNullOrEmpty(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| ArgumentEmptyException |
|
ThrowIfNullOrWhitespace(String, String)
Validates and throws either an System.ArgumentNullException, ArgumentEmptyException or System.ArgumentException if the specified value is respectively null, empty or consist only of white-space characters.
Declaration
public static void ThrowIfNullOrWhitespace(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| ArgumentEmptyException |
|
| System.ArgumentException |
|
ThrowIfNullOrWhitespace(String, String, String)
Validates and throws either an System.ArgumentNullException, ArgumentEmptyException or System.ArgumentException if the specified value is respectively null, empty or consist only of white-space characters.
Declaration
public static void ThrowIfNullOrWhitespace(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| ArgumentEmptyException |
|
| System.ArgumentException |
|
ThrowIfNumber(String, String)
Validates and throws an System.ArgumentException if the specified value is a number.
Declaration
public static void ThrowIfNumber(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNumber(String, String, NumberStyles)
Validates and throws an System.ArgumentException if the specified value is a number.
Declaration
public static void ThrowIfNumber(string value, string paramName, NumberStyles styles)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNumber(String, String, NumberStyles, IFormatProvider)
Validates and throws an System.ArgumentException if the specified value is a number.
Declaration
public static void ThrowIfNumber(string value, string paramName, NumberStyles styles, IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
| System.IFormatProvider | provider | An System.IFormatProvider that supplies culture-specific formatting information about |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNumber(String, String, String)
Validates and throws an System.ArgumentException if the specified value is a number.
Declaration
public static void ThrowIfNumber(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNumber(String, String, String, NumberStyles)
Validates and throws an System.ArgumentException if the specified value is a number.
Declaration
public static void ThrowIfNumber(string value, string paramName, string message, NumberStyles styles)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfNumber(String, String, String, NumberStyles, IFormatProvider)
Validates and throws an System.ArgumentException if the specified value is a number.
Declaration
public static void ThrowIfNumber(string value, string paramName, string message, NumberStyles styles, IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
| System.Globalization.NumberStyles | styles | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of |
| System.IFormatProvider | provider | An System.IFormatProvider that supplies culture-specific formatting information about |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfSame<T>(T, T, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are of the same instance as the y object.
Declaration
public static void ThrowIfSame<T>(T x, T y, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfSame<T>(T, T, String, String)
Validates and throws an System.ArgumentOutOfRangeException if the specified x object are of the same instance as the y object.
Declaration
public static void ThrowIfSame<T>(T x, T y, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object to compare. |
| T | y | The second object to compare. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of objects to compare. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
ThrowIfTrue(Boolean, String)
Validates and throws an System.ArgumentException if the specified value is true.
Declaration
public static void ThrowIfTrue(bool value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfTrue(Boolean, String, String)
Validates and throws an System.ArgumentException if the specified value is true.
Declaration
public static void ThrowIfTrue(bool value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfUri(String, String)
Validates and throws an System.ArgumentException if the specified value has the format of an System.Uri.
Declaration
public static void ThrowIfUri(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfUri(String, UriKind, String, String)
Validates and throws an System.ArgumentException if the specified value has the format of an System.Uri.
Declaration
public static void ThrowIfUri(string value, UriKind uriKind, string paramName, string message = "Value cannot be an URI.")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.UriKind | uriKind | The type of the URI. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfWhiteSpace(String, String)
Validates and throws an ArgumentEmptyException if the specified value consist only of white-space characters.
Declaration
public static void ThrowIfWhiteSpace(string value, string paramName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
ThrowIfWhiteSpace(String, String, String)
Validates and throws an System.ArgumentException if the specified value consist only of white-space characters.
Declaration
public static void ThrowIfWhiteSpace(string value, string paramName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value to be evaluated. |
| System.String | paramName | The name of the parameter that caused the exception. |
| System.String | message | A message that describes the error. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|