Skip to main content

Definition

Assembly: CloudNimble.EasyAF.Core.dll Namespace: CloudNimble.EasyAF.Core Inheritance: System.Object

Syntax

CloudNimble.EasyAF.Core.Ensure

Summary

Provides methods for ensuring that method arguments meet specific criteria. This class provides a consistent way to validate arguments and throw appropriate exceptions.

Examples

public void ProcessData(string input, List<string> items)
{
    Ensure.ArgumentNotNull(input, nameof(input));
    Ensure.ArgumentNotNull(items, nameof(items));

    // Process the validated arguments
}

Methods

ArgumentNotNull

Ensures that the specified argument is not null.

Syntax

public static void ArgumentNotNull(object argument, string argumentName)

Parameters

NameTypeDescription
argumentobjectThe argument to validate.
argumentNamestringThe name of the argument being validated.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when argument is null.

ArgumentNotNullOrWhiteSpace

Ensures that the specified argument is not null or whitespace.

Syntax

public static void ArgumentNotNullOrWhiteSpace(string argument, string argumentName)

Parameters

NameTypeDescription
argumentstringThe argument to validate.
argumentNamestringThe name of the argument being validated.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when argument is null or whitespace.