New to Telerik Document Processing? Start a free 30-day trial

Guard

Class

Provides methods for checking whether the parameters of methods fall within the expected conditions.

Definition

Namespace:Telerik.Documents.Spreadsheet.Utilities

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Syntax:

C#
public static class Guard

Inheritance: objectGuard

Methods

Asserts the specified condition.

C#
public static void Assert(bool condition, string message)
Parameters:conditionbool

The condition.

messagestring

The message to throw in case the condition is not met.

Throws an exception if the parameter contains null values.

C#
public static void ThrowExceptionIfContainsNull<T>(IEnumerable<T> param, string paramName) where T : class
Parameters:paramIEnumerable<T>

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if the parameter contains null or empty values.

C#
public static void ThrowExceptionIfContainsNullOrEmpty(IEnumerable<string> param, string paramName)
Parameters:paramIEnumerable<string>

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if the parameters is greater than the upper bound.

C#
public static void ThrowExceptionIfGreaterThan<T>(T upperBound, T param, string paramName) where T : IComparable<T>
Parameters:upperBoundT

The upper bound.

paramT

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if the column index is invalid.

C#
public static void ThrowExceptionIfInvalidColumnIndex(int columnIndex)
Parameters:columnIndexint

Index of the column.

Throws an exception if the row index is invalid.

C#
public static void ThrowExceptionIfInvalidRowIndex(int rowIndex)
Parameters:rowIndexint

Index of the row.

Throws an exception if the parameter is less than the lower bound.

C#
public static void ThrowExceptionIfLessThan<T>(T lowerBound, T param, string paramName) where T : IComparable<T>
Parameters:lowerBoundT

The lower bound.

paramT

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if the parameter is not equal to a value.

C#
public static void ThrowExceptionIfNotEqual<T>(T expected, T param, string paramName)
Parameters:expectedT

The expected value.

paramT

The parameters.

paramNamestring

Name of the parameter.

Throws an exception if the parameter is not null.

C#
public static void ThrowExceptionIfNotNull<T>(T param, string paramName)
Parameters:paramT

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if the parameter is null.

C#
public static void ThrowExceptionIfNull<T>(T param, string paramName)
Parameters:paramT

The parameter.

paramNamestring

Name of the parameter.

Throws the exception if the parameter is null or empty.

C#
public static void ThrowExceptionIfNullOrEmpty(string param, string paramName)
Parameters:paramstring

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if the parameter is null or empty.

C#
public static void ThrowExceptionIfNullOrEmpty<T>(IEnumerable<T> param, string paramName) where T : class
Parameters:paramIEnumerable<T>

The parameter.

paramNamestring

Name of the parameter.

Throws an exception if out of range.

C#
public static void ThrowExceptionIfOutOfRange<T>(T lowerBound, T upperBound, T param, string paramName) where T : IComparable<T>
Parameters:lowerBoundT

The lower bound.

upperBoundT

The upper bound.

paramT

The parameter.

paramNamestring

Name of the parameter.