1. Stylelabs.M.Sdk.Utilities

Class SdkGuard

Sdk Guard.

Inheritance

object

SdkGuard

Namespace: StylelabsStylelabs.MSdkUtilities

Assembly: Stylelabs.M.Sdk.dll

Syntax

public static class SdkGuard

Methods

GreaterThan(string, long, long)

Checks if the specified long is greater than a given minimum. Otherwise if the specified long is lower or equal to given minimum, fail.

Declaration

public static void GreaterThan(string argument, long value, long minimum)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
longvalueThe value of the argument.
longminimumThe minimum.

NotNegative(string, long)

Checks if the specified long is negative.

Declaration

public static void NotNegative(string argument, long value)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
longvalueThe value of the argument.

NotNull(string, object)

Checks if the specified value is null.

Declaration

public static void NotNull(string argument, object value)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
objectvalueThe value of the argument.

NotNullEach(string, T)

Checks if the specified collection is null or contains null values.

Declaration

public static void NotNullEach<T>(string argument, T value) where T : IEnumerable

Parameters

TypeNameDescription
stringargumentThe name of the argument.
TvalueThe value of the argument.

Type Parameters

NameDescription
TType of the collection.

NotNullMaxItems(string, IEnumerable, int)

Checks that the specified items does not contain more than maxItems.

Declaration

public static void NotNullMaxItems<T>(string parameterName, IEnumerable<T> items, int maxItems)

Parameters

TypeNameDescription
stringparameterNameName of the parameter.
IEnumerable<>itemsCollection to check.
intmaxItemsThe maximum number of allowed items within the items collection.

Type Parameters

NameDescription
TThe type parameter.

NotNullMaxOneId(string, IEnumerable)

The ids cannot be null. It can be empty, but it cannot contain more than 1 value. The value must be a strictly positive id, if it exists.

Declaration

public static void NotNullMaxOneId(string parameterName, IEnumerable<long> ids)

Parameters

TypeNameDescription
stringparameterNameName of the parameter.
IEnumerable<>longidsCollection to check.

NotNullOrEmptyCollection(string, T)

Checks if the specified collection is null or empty.

Declaration

public static void NotNullOrEmptyCollection<T>(string argument, T value) where T : IEnumerable

Parameters

TypeNameDescription
stringargumentThe name of the argument.
TvalueThe value of the argument.

Type Parameters

NameDescription
TType of the collection.

NotNullOrInvariantCulture(string, CultureInfo)

Checks if the specified culture is null or invariant culture.

Declaration

public static void NotNullOrInvariantCulture(string argument, CultureInfo culture)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
CultureInfocultureThe culture.

NotNullOrInvariantCultureEach(string, IEnumerable)

Checks if the specified culture is null or invariant culture.

Declaration

public static void NotNullOrInvariantCultureEach(string argument, IEnumerable<CultureInfo> cultures)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
IEnumerable<>CultureInfoculturesThe cultures.

NotNullOrWhiteSpace(string, string)

Checks if the specified value is null, an empty string or white space string.

Declaration

public static void NotNullOrWhiteSpace(string argument, string value)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
stringvalueThe value of the argument.

NotNullOrWhiteSpaceEach(string, IEnumerable)

Checks if the specified collection is null or contains null or white space strings.

Declaration

public static void NotNullOrWhiteSpaceEach(string argument, IEnumerable<string> value)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
IEnumerable<>stringvalueThe value of the argument.

StrictlyPositive(string, int)

Checks if the specified number is strictly positive, i.e. greater than zero.

Declaration

public static void StrictlyPositive(string argument, int value)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
intvalueThe value of the argument.

StrictlyPositive(string, TimeSpan)

Checks if the specified time span is strictly positive, i.e. greater than zero.

Declaration

public static void StrictlyPositive(string argument, TimeSpan value)

Parameters

TypeNameDescription
stringargumentThe name of the argument.
TimeSpanvalueThe value of the argument.

ValidId(string, long?)

If the id is not null, it must be strictly positive.

Declaration

public static void ValidId(string parameterName, long? id)

Parameters

TypeNameDescription
stringparameterNameName of the parameter.
longidId to check.

ValidIds(string, IEnumerable)

The ids cannot be null, and every id must be strictly positive.

Declaration

public static void ValidIds(string parameterName, IEnumerable<long> ids)

Parameters

TypeNameDescription
stringparameterNameName of the parameter.
IEnumerable<>longidsIds to check.
If you have suggestions for improving this article, let us know!