Table of Contents

ThrowIfNotContainsInterface Method

Definition

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

ThrowIfNotContainsInterface<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 ThrowIfNotContainsInterface<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 (that must be an interface) 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.

ArgumentException

types does not satisfy the condition of being an interface.

ThrowIfNotContainsInterface<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 ThrowIfNotContainsInterface<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 (that must be an interface) 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.

ArgumentException

types does not satisfy the condition of being an interface.

ThrowIfNotContainsInterface(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 ThrowIfNotContainsInterface(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 (that each must be an interface) 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.

ArgumentException

types does not satisfy the condition of being an interface.