Table of Contents

ThrowIfNotContainsType Method

Definition

Namespace
Cuemon
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Validator.cs

ThrowIfNotContainsType(Type, Type[], string, string)

Validates and throws an ArgumentOutOfRangeException if the specified argument is not contained within at least one of the specified types.

public static void ThrowIfNotContainsType(Type argument, Type[] types, string message = "Specified argument is not contained within at least one of the specified types.", string paramName = null)

Parameters

argument Type

The value to be evaluated.

types Type[]

A Type array that contains zero or more types to match with the type of argument.

message string

A message that describes the error.

paramName string

The name of the parameter that caused the exception.

Remarks

Use ToArrayOf<T>(params T[]) to substitute earlier signature of params Type[] types.

Exceptions

ArgumentNullException

argument is null - or - types is null.

ArgumentOutOfRangeException

argument is not contained within at least one of the specified types.

ThrowIfNotContainsType(object, Type[], string, string)

Validates and throws an ArgumentOutOfRangeException if the specified argument is not contained within at least one of the specified types.

public static void ThrowIfNotContainsType(object argument, Type[] types, string message = "Specified argument is not contained within at least one of the specified types.", string paramName = null)

Parameters

argument object

The value to be evaluated.

types Type[]

A Type array that contains zero or more types to match with the type of argument.

message string

A message that describes the error.

paramName string

The name of the parameter that caused the exception.

Remarks

Use ToArrayOf<T>(params T[]) to substitute earlier signature of params Type[] types.

Exceptions

ArgumentNullException

argument is null - or - types is null.

ArgumentOutOfRangeException

argument is not contained within at least one of the specified types.

ThrowIfNotContainsType<T>(string, params Type[])

Validates and throws a TypeArgumentOutOfRangeException if the specified T is not contained within at least one of the specified types.

public static void ThrowIfNotContainsType<T>(string typeParamName, params Type[] types)

Parameters

typeParamName string

The name of the type parameter that caused the exception.

types Type[]

A variable number of Type arguments to match with the type of T.

Type Parameters

T

Exceptions

ArgumentNullException

types is null.

TypeArgumentOutOfRangeException

T is not contained within at least one of the specified types.

ThrowIfNotContainsType<T>(string, string, params Type[])

Validates and throws a TypeArgumentOutOfRangeException if the specified T is not contained within at least one of the specified types.

public static void ThrowIfNotContainsType<T>(string typeParamName, string message, params Type[] types)

Parameters

typeParamName string

The name of the type parameter that caused the exception.

message string

A message that describes the error.

types Type[]

A variable number of Type arguments to match with the type of T.

Type Parameters

T

Exceptions

ArgumentNullException

types is null.

TypeArgumentOutOfRangeException

T is not contained within at least one of the specified types.