Table of Contents

ThrowIfTrue Method

Definition

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

ThrowIfTrue(bool, string, string, string)

Validates and throws an ArgumentException if the specified condition is true.

public static void ThrowIfTrue(bool condition, string paramName, string message = "Value is not in a valid state.", string expression = null)

Parameters

condition bool

The value to be evaluated.

paramName string

The name of the parameter that caused the exception.

message string

A message that describes the error.

expression string

The condition expressed as a string.

Exceptions

ArgumentException

condition is true.

ThrowIfTrue(Func<bool>, string, string, string)

Validates and throws an ArgumentException if the specified predicate returns true.

public static void ThrowIfTrue(Func<bool> predicate, string paramName, string message = "Value is not in a valid state.", string expression = null)

Parameters

predicate Func<bool>

The function delegate that determines if an ArgumentException is thrown.

paramName string

The name of the parameter that caused the exception.

message string

A message that describes the error.

expression string

The predicate expressed as a string.

Exceptions

ArgumentException

predicate returned true.