ThrowIf

public static T ThrowIf<T>(this T val, Func<T, bool> predicate, Func<Exception> exceptionFunc)
{
    if (predicate(val))
        throw exceptionFunc();
    return val;
}
Example:
int? tempId = Submit();

tempId.ThrowIf(i=>!i.HasValue,()=>ServiceFault<FatalExceptionFault>.FaultFor("Unable to submit to Temp Database!"));

Description

Throw's a given exception is a given predicate is True

Details

Double click on the code to select all.

 

;