Table of Contents

ThrowIfInvalidState Method

Definition

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

ThrowIfInvalidState(bool, string, string)

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

public static void ThrowIfInvalidState(bool condition, string message = "Operation is not valid due to the current state of the object.", string expression = null)

Parameters

condition bool

The value that determines if an InvalidOperationException is thrown.

message string

A message that describes the error.

expression string

The condition expressed as a string.

Remarks

This guard should be called when validating the state of an object - not when validating arguments passed to a member.

Exceptions

InvalidOperationException

condition is true.