 | ExceptionExtensionsThrowIfT Method |
Throws the specified exception if the predicate results in a true value
based on the parameter supplied
Namespace:
TestHelperExtensions
Assembly:
CBI.TestHelperExtensions (in CBI.TestHelperExtensions.dll) Version: 2.1.0.1
Syntaxpublic static void ThrowIf<T>(
this Exception exception,
Func<T, bool> predicate,
T parameter
)
<ExtensionAttribute>
Public Shared Sub ThrowIf(Of T) (
exception As Exception,
predicate As Func(Of T, Boolean),
parameter As T
)
public:
[ExtensionAttribute]
generic<typename T>
static void ThrowIf(
Exception^ exception,
Func<T, bool>^ predicate,
T parameter
)
[<ExtensionAttribute>]
static member ThrowIf :
exception : Exception *
predicate : Func<'T, bool> *
parameter : 'T -> unit
Parameters
- exception
- Type: SystemException
The exception to be thrown (conditionally) - predicate
- Type: SystemFuncT, Boolean
A function returning a bool containing functionality
to determine if the exception should be thrown or not - parameter
- Type: T
The parameter value used in the predicate function
Type Parameters
- T
- The data type of the parameter
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
Exception. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
See Also