Class SdkGuard
Sdk Guard.
Inheritance
Namespace: StylelabsStylelabs.MSdkUtilities
Assembly: Stylelabs.M.Sdk.dll
Syntax
public static class SdkGuardMethods
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
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| long | value |
The value of the argument. |
| long | minimum |
The minimum. |
NotNegative(string, long)
Checks if the specified long is negative.
Declaration
public static void NotNegative(string argument, long value)Parameters
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| long | value |
The value of the argument. |
NotNull(string, object)
Checks if the specified value is null.
Declaration
public static void NotNull(string argument, object value)Parameters
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| object | value |
The value of the argument. |
NotNullEach<T>(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 : IEnumerableParameters
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| T | value |
The value of the argument. |
Type Parameters
| Name | Description |
|---|---|
| T |
Type of the collection. |
NotNullMaxItems<T>(string, IEnumerable<T>, 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
| Type | Name | Description |
|---|---|---|
| string | parameterName |
Name of the parameter. |
| IEnumerable<> | items |
Collection to check. |
| int | maxItems |
The maximum number of allowed items within the |
Type Parameters
| Name | Description |
|---|---|
| T |
The type parameter. |
NotNullMaxOneId(string, IEnumerable<long>)
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
| Type | Name | Description |
|---|---|---|
| string | parameterName |
Name of the parameter. |
| IEnumerable<>long | ids |
Collection to check. |
NotNullOrEmptyCollection<T>(string, T)
Checks if the specified collection is null or empty.
Declaration
public static void NotNullOrEmptyCollection<T>(string argument, T value) where T : IEnumerableParameters
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| T | value |
The value of the argument. |
Type Parameters
| Name | Description |
|---|---|
| T |
Type 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
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| CultureInfo | culture |
The culture. |
NotNullOrInvariantCultureEach(string, IEnumerable<CultureInfo>)
Checks if the specified culture is null or invariant culture.
Declaration
public static void NotNullOrInvariantCultureEach(string argument, IEnumerable<CultureInfo> cultures)Parameters
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| IEnumerable<>CultureInfo | cultures |
The 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
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| string | value |
The value of the argument. |
NotNullOrWhiteSpaceEach(string, IEnumerable<string>)
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
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| IEnumerable<>string | value |
The 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
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| int | value |
The 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
| Type | Name | Description |
|---|---|---|
| string | argument |
The name of the argument. |
| TimeSpan | value |
The 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
| Type | Name | Description |
|---|---|---|
| string | parameterName |
Name of the parameter. |
| long | id |
Id to check. |
ValidIds(string, IEnumerable<long>)
The ids cannot be null, and every id must be strictly positive.
Declaration
public static void ValidIds(string parameterName, IEnumerable<long> ids)Parameters
| Type | Name | Description |
|---|---|---|
| string | parameterName |
Name of the parameter. |
| IEnumerable<>long | ids |
Ids to check. |