ThrowIfContainsInterface Method
Definition
ThrowIfContainsInterface<T>(string, params Type[])
Validates and throws a TypeArgumentOutOfRangeException if the specified T is contained within at least one of the specified types.
public static void ThrowIfContainsInterface<T>(string typeParamName, params Type[] types)
Parameters
typeParamNamestringThe name of the type parameter that caused the exception.
typesType[]A variable number of Type arguments (that must be an interface) to match with the type of
T.
Type Parameters
T
Exceptions
- ArgumentNullException
typesis null.- TypeArgumentOutOfRangeException
Tis contained within at least one of the specifiedtypes.- ArgumentException
typesdoes not satisfy the condition of being an interface.
ThrowIfContainsInterface<T>(string, string, params Type[])
Validates and throws an TypeArgumentOutOfRangeException if the specified T is contained within at least one of the specified types.
public static void ThrowIfContainsInterface<T>(string typeParamName, string message, params Type[] types)
Parameters
typeParamNamestringThe name of the type parameter that caused the exception.
messagestringA message that describes the error.
typesType[]A variable number of Type arguments (that must be an interface) to match with the type of
T.
Type Parameters
T
Exceptions
- ArgumentNullException
typesis null.- TypeArgumentOutOfRangeException
Tis contained within at least one of the specifiedtypes.- ArgumentException
typesdoes not satisfy the condition of being an interface.
ThrowIfContainsInterface(Type, Type[], string, string)
Validates and throws an ArgumentOutOfRangeException if the specified argument is contained within at least one of the specified types.
public static void ThrowIfContainsInterface(Type argument, Type[] types, string message = "Specified argument is contained within at least one of the specified types.", string paramName = null)
Parameters
argumentTypeThe value to be evaluated.
typesType[]A Type array that contains zero or more types (that each must be an interface) to match with the type of
argument.messagestringA message that describes the error.
paramNamestringThe name of the parameter that caused the exception.
Remarks
Use ToArrayOf<T>(params T[]) to substitute earlier signature of params Type[] types.
Exceptions
- ArgumentNullException
argumentis null - or -typesis null.- ArgumentOutOfRangeException
argumentis contained within at least one of the specifiedtypes.- ArgumentException
typesdoes not satisfy the condition of being an interface.